Page MenuHomeFreeBSD

Put sections into expected offset in binary format.
ClosedPublic

Authored by ray on Sep 27 2019, 10:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 17 2024, 3:52 AM
Unknown Object (File)
Nov 17 2024, 3:23 AM
Unknown Object (File)
Nov 17 2024, 1:49 AM
Unknown Object (File)
Oct 26 2024, 6:42 PM
Unknown Object (File)
Oct 14 2024, 9:06 PM
Unknown Object (File)
Oct 14 2024, 8:35 PM
Unknown Object (File)
Oct 14 2024, 8:32 PM
Unknown Object (File)
Oct 14 2024, 8:07 PM
Subscribers

Details

Summary

Calculate binary file offset using address field, bacause software know only offset to known data, not where to load segment.
With that patch, kernel .data section can have any alignment - kernel works.

PR: 235391

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 26745
Build 25097: arc lint + arc unit

Event Timeline

contrib/elftoolchain/elfcopy/binary.c
81

Why keep "base"?

contrib/elftoolchain/elfcopy/binary.c
81

As flags. Because sh_addr must not use special values.

contrib/elftoolchain/elfcopy/binary.c
81

That claim should apply to sh_offset as well, shouldn't it? For position-independent objects we will have sh_offset == sh_addr.

contrib/elftoolchain/elfcopy/binary.c
81

After objcopy -O binary done, nobody know it is PIC, loadable or anything else.

Can you show the readelf -S output for the input file where this change matters? The change looks ok to me, but I do not understand why it is useful.

Can you show the readelf -S output for the input file where this change matters? The change looks ok to me, but I do not understand why it is useful.

https://gist.github.com/rayddteam/270b5e564566c7a64841d58a9b34d7cd

markj added inline comments.
contrib/elftoolchain/elfcopy/binary.c
81

Sure, but here we are talking about the input file, not the output file.

Anyway, if you insist on keeping both variables, I would rename base to baseoff.

116

Should be baseaddr now.

This revision is now accepted and ready to land.Sep 28 2019, 5:09 PM

Rename base to baseoff. Fix comment.

This revision now requires review to proceed.Sep 29 2019, 9:17 PM
ray marked 2 inline comments as done.Sep 29 2019, 9:17 PM
contrib/elftoolchain/elfcopy/binary.c
81

About claim: not exact same. baseoff(base before) is off_t, which is big enough to never reach '-1' and in that case used on value, that can't be negative. So, not clearly, but can be used with special value. About Elf64_Addr, we can't be sure what address will be selected to start kernel on platform. We can use special value 0xff..f, but it will looks more magic than just -1 :)

This revision is now accepted and ready to land.Sep 29 2019, 10:19 PM
This revision was automatically updated to reflect the committed changes.