[PATCH] D71035: [llvm-objcopy][ELF] -O binary: use LMA instead of sh_offset to decide where to write section contents
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 9 03:25:00 PST 2019
jhenderson added a comment.
I've been playing around with the YAML from the test to experiment with other situations using GNU objcopy, and I'm not convinced that your statement about the algorithm is quite accurate, and indeed I see behaviour differences between GNU objcopy and llvm-objcopy with this patch. Unfortunately, I haven't been able to figure out what the actual algorithm is, so it's possible I'm just misunderstanding something. Here is an example I used:
Input:
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x1000
AddressAlign: 0x0000000000001000
Content: "c3c3c3c3"
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x3000
AddressAlign: 0x0000000000001000
Content: "3232"
- Name: .baz
Type: SHT_PROGBITS
Size: 0x2000
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_R, PF_W ]
VAddr: 0x2000
PAddr: 0x4000
FileSize: 0x1800
MemSize: 0x1800
Sections:
- Section: .data
GNU objcopy output:
000000 c3c3 c3c3 0000 0000 0000 0000 0000 0000
000010 0000 0000 0000 0000 0000 0000 0000 0000
*
003000 3232
003002
llvm-objcopy output:
000000 c3c3 c3c3 0000 0000 0000 0000 0000 0000
000010 0000 0000 0000 0000 0000 0000 0000 0000
*
004000 3232
004002
I also noticed several differences that may be unrelated to this issue when sections are not in segments. Speaking of which, did you mean for this to be the case for .text in this test?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71035/new/
https://reviews.llvm.org/D71035
More information about the llvm-commits
mailing list