Changeset View
Standalone View
test/tools/llvm-objcopy/binary-paddr.test
- This file was added.
# RUN: yaml2obj %s -o %t | |||||
# RUN: llvm-objcopy -O binary %t %t2 | |||||
jhenderson: I wonder whether it would be beneficial to have a another test-case here, or possibly extend… | |||||
Not Done ReplyInline ActionsThat seems like a good additional thing to add. The gap should be preserved for segments but not for sections that are outside of segments. jakehehrlich: That seems like a good additional thing to add. The gap should be preserved for segments but… | |||||
# RUN: od -t x2 -v %t2 | FileCheck %s | |||||
# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE | |||||
!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: 0x2000 | |||||
AddressAlign: 0x0000000000000004 | |||||
Content: "3232" | |||||
ProgramHeaders: | |||||
- Type: PT_LOAD | |||||
Flags: [ PF_X, PF_R ] | |||||
VAddr: 0x1000 | |||||
PAddr: 0x1000 | |||||
Align: 0x1000 | |||||
Sections: | |||||
- Section: .text | |||||
- Type: PT_LOAD | |||||
Flags: [ PF_R, PF_W ] | |||||
VAddr: 0x2000 | |||||
jakehehrlichUnsubmitted Not Done ReplyInline ActionsWe don't know where the .data section will end up only that it will have 4-byte alignment It's possible (even quite likely) for the the offset of the .data section (which decides the offset of the program header unfortunately, not the other way around) to be such that the p_offset % p_align != p_vaddr % p_align. This is still not a valid ELF file (at least it isn't assured). jakehehrlich: We don't know where the .data section will end up only that it will have 4-byte alignment It's… | |||||
owenpshawAuthorUnsubmitted Not Done ReplyInline ActionsI guess I'm missing something with this alignment stuff. Having possibly invalid values in the elf doesn't seem to affect what we're testing, but I agree it'd be good to use proper input if possible. What values would make it valid? owenpshaw: I guess I'm missing something with this alignment stuff. Having possibly invalid values in the… | |||||
jhendersonUnsubmitted Not Done ReplyInline ActionsMaybe try PAddr 0x4000 and PVaddr 0x2000, and then use .data AddrAlign of 0x1000? jhenderson: Maybe try PAddr 0x4000 and PVaddr 0x2000, and then use .data AddrAlign of 0x1000? | |||||
jakehehrlichUnsubmitted Not Done ReplyInline ActionsThat would work. jakehehrlich: That would work. | |||||
PAddr: 0x1008 | |||||
Align: 0x1000 | |||||
Sections: | |||||
- Section: .data | |||||
# CHECK: 0000000 c3c3 c3c3 0000 0000 3232 | |||||
# SIZE: 10 |
I wonder whether it would be beneficial to have a another test-case here, or possibly extend this one to have a gap in the physical address range, a bit like binary-segment-layout does for virtual addresses. I assume that the binary layout code should then preserve the gap between these two segments.