diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -848,7 +848,7 @@ IO.mapOptional("Flags", Phdr.Flags, ELFYAML::ELF_PF(0)); IO.mapOptional("Sections", Phdr.Sections); IO.mapOptional("VAddr", Phdr.VAddr, Hex64(0)); - IO.mapOptional("PAddr", Phdr.PAddr, Hex64(0)); + IO.mapOptional("PAddr", Phdr.PAddr, Phdr.VAddr); IO.mapOptional("Align", Phdr.Align); IO.mapOptional("FileSize", Phdr.FileSize); IO.mapOptional("MemSize", Phdr.MemSize); diff --git a/llvm/test/tools/llvm-elfabi/binary-read-add-soname.test b/llvm/test/tools/llvm-elfabi/binary-read-add-soname.test --- a/llvm/test/tools/llvm-elfabi/binary-read-add-soname.test +++ b/llvm/test/tools/llvm-elfabi/binary-read-add-soname.test @@ -33,7 +33,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x0000 - PAddr: 0x0000 Align: 8 Sections: - Section: .dynstr @@ -41,7 +40,6 @@ - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x0008 - PAddr: 0x0008 Sections: - Section: .dynamic diff --git a/llvm/test/tools/llvm-elfabi/binary-read-arch.test b/llvm/test/tools/llvm-elfabi/binary-read-arch.test --- a/llvm/test/tools/llvm-elfabi/binary-read-arch.test +++ b/llvm/test/tools/llvm-elfabi/binary-read-arch.test @@ -33,7 +33,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x0000 - PAddr: 0x0000 Align: 8 Sections: - Section: .dynstr @@ -41,7 +40,6 @@ - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x0008 - PAddr: 0x0008 Sections: - Section: .dynamic diff --git a/llvm/test/tools/llvm-elfabi/binary-read-bad-soname.test b/llvm/test/tools/llvm-elfabi/binary-read-bad-soname.test --- a/llvm/test/tools/llvm-elfabi/binary-read-bad-soname.test +++ b/llvm/test/tools/llvm-elfabi/binary-read-bad-soname.test @@ -35,7 +35,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x0000 - PAddr: 0x0000 Align: 8 Sections: - Section: .dynstr @@ -43,7 +42,6 @@ - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x0008 - PAddr: 0x0008 Sections: - Section: .dynamic diff --git a/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test b/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test --- a/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test +++ b/llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test @@ -35,7 +35,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Align: 8 Sections: - Section: .dynstr @@ -43,7 +42,6 @@ - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x1008 - PAddr: 0x1008 Sections: - Section: .dynamic diff --git a/llvm/test/tools/llvm-elfabi/binary-read-neededlibs-bad-offset.test b/llvm/test/tools/llvm-elfabi/binary-read-neededlibs-bad-offset.test --- a/llvm/test/tools/llvm-elfabi/binary-read-neededlibs-bad-offset.test +++ b/llvm/test/tools/llvm-elfabi/binary-read-neededlibs-bad-offset.test @@ -39,7 +39,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Align: 8 Sections: - Section: .dynstr @@ -47,7 +46,6 @@ - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x1024 - PAddr: 0x1024 Sections: # CHECK: DT_NEEDED string offset (0x000000000000ffff) outside of dynamic string table diff --git a/llvm/test/tools/llvm-elfabi/binary-read-neededlibs.test b/llvm/test/tools/llvm-elfabi/binary-read-neededlibs.test --- a/llvm/test/tools/llvm-elfabi/binary-read-neededlibs.test +++ b/llvm/test/tools/llvm-elfabi/binary-read-neededlibs.test @@ -38,7 +38,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Align: 8 Sections: - Section: .dynstr @@ -46,7 +45,6 @@ - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x1024 - PAddr: 0x1024 Sections: # CHECK: NeededLibs: diff --git a/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strsz.test b/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strsz.test --- a/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strsz.test +++ b/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strsz.test @@ -30,7 +30,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x0000 - PAddr: 0x0000 Align: 8 Sections: - Section: .dynstr @@ -38,7 +37,6 @@ - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x0008 - PAddr: 0x0008 Sections: - Section: .dynamic diff --git a/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strtab.test b/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strtab.test --- a/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strtab.test +++ b/llvm/test/tools/llvm-elfabi/binary-read-no-dt-strtab.test @@ -29,7 +29,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x0000 - PAddr: 0x0000 Align: 8 Sections: - Section: .dynstr @@ -37,7 +36,6 @@ - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x0008 - PAddr: 0x0008 Sections: - Section: .dynamic diff --git a/llvm/test/tools/llvm-elfabi/binary-read-replace-soname.test b/llvm/test/tools/llvm-elfabi/binary-read-replace-soname.test --- a/llvm/test/tools/llvm-elfabi/binary-read-replace-soname.test +++ b/llvm/test/tools/llvm-elfabi/binary-read-replace-soname.test @@ -37,7 +37,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Align: 8 Sections: - Section: .dynstr @@ -45,7 +44,6 @@ - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x1018 - PAddr: 0x1018 Sections: - Section: .dynamic diff --git a/llvm/test/tools/llvm-elfabi/binary-read-soname-no-null.test b/llvm/test/tools/llvm-elfabi/binary-read-soname-no-null.test --- a/llvm/test/tools/llvm-elfabi/binary-read-soname-no-null.test +++ b/llvm/test/tools/llvm-elfabi/binary-read-soname-no-null.test @@ -36,7 +36,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Align: 8 Sections: - Section: .dynstr @@ -44,7 +43,6 @@ - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x1018 - PAddr: 0x1018 Sections: - Section: .dynamic diff --git a/llvm/test/tools/llvm-elfabi/binary-read-soname.test b/llvm/test/tools/llvm-elfabi/binary-read-soname.test --- a/llvm/test/tools/llvm-elfabi/binary-read-soname.test +++ b/llvm/test/tools/llvm-elfabi/binary-read-soname.test @@ -36,7 +36,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Align: 8 Sections: - Section: .dynstr @@ -44,7 +43,6 @@ - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x1018 - PAddr: 0x1018 Sections: - Section: .dynamic diff --git a/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml b/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml --- a/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml +++ b/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml @@ -388,7 +388,6 @@ - Type: PT_LOAD Flags: [ PF_X, PF_R ] VAddr: 0x0000000000400000 - PAddr: 0x0000000000400000 Align: 1024 Sections: - Section: .interp diff --git a/llvm/test/tools/llvm-objcopy/ELF/add-symbol.test b/llvm/test/tools/llvm-objcopy/ELF/add-symbol.test --- a/llvm/test/tools/llvm-objcopy/ELF/add-symbol.test +++ b/llvm/test/tools/llvm-objcopy/ELF/add-symbol.test @@ -47,14 +47,12 @@ - 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 - PAddr: 0x2000 Align: 0x1000 Sections: - Section: .data diff --git a/llvm/test/tools/llvm-objcopy/ELF/binary-first-seg-offset-zero.test b/llvm/test/tools/llvm-objcopy/ELF/binary-first-seg-offset-zero.test --- a/llvm/test/tools/llvm-objcopy/ELF/binary-first-seg-offset-zero.test +++ b/llvm/test/tools/llvm-objcopy/ELF/binary-first-seg-offset-zero.test @@ -26,7 +26,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Sections: - Section: .note - Section: .rodata diff --git a/llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test b/llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test --- a/llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test +++ b/llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test @@ -127,6 +127,5 @@ - Type: PT_LOAD Flags: [ PF_R, PF_W ] VAddr: 0x3000 - PAddr: 0x3000 Sections: - Section: .data diff --git a/llvm/test/tools/llvm-objcopy/ELF/binary-remove-all-but-one.test b/llvm/test/tools/llvm-objcopy/ELF/binary-remove-all-but-one.test --- a/llvm/test/tools/llvm-objcopy/ELF/binary-remove-all-but-one.test +++ b/llvm/test/tools/llvm-objcopy/ELF/binary-remove-all-but-one.test @@ -35,7 +35,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Sections: - Section: .text - Section: .text2 diff --git a/llvm/test/tools/llvm-objcopy/ELF/binary-remove-end.test b/llvm/test/tools/llvm-objcopy/ELF/binary-remove-end.test --- a/llvm/test/tools/llvm-objcopy/ELF/binary-remove-end.test +++ b/llvm/test/tools/llvm-objcopy/ELF/binary-remove-end.test @@ -35,7 +35,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Sections: - Section: .text - Section: .text2 diff --git a/llvm/test/tools/llvm-objcopy/ELF/binary-remove-middle.test b/llvm/test/tools/llvm-objcopy/ELF/binary-remove-middle.test --- a/llvm/test/tools/llvm-objcopy/ELF/binary-remove-middle.test +++ b/llvm/test/tools/llvm-objcopy/ELF/binary-remove-middle.test @@ -35,7 +35,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Sections: - Section: .text - Section: .text2 diff --git a/llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align-binary.test b/llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align-binary.test --- a/llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align-binary.test +++ b/llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align-binary.test @@ -25,14 +25,12 @@ - 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: 0x1008 - PAddr: 0x1008 Align: 0x1000 Sections: - Section: .data diff --git a/llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align.test b/llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align.test --- a/llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align.test +++ b/llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align.test @@ -25,14 +25,12 @@ - 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: 0x1008 - PAddr: 0x1008 Align: 0x1000 Sections: - Section: .data diff --git a/llvm/test/tools/llvm-objcopy/ELF/empty-section.test b/llvm/test/tools/llvm-objcopy/ELF/empty-section.test --- a/llvm/test/tools/llvm-objcopy/ELF/empty-section.test +++ b/llvm/test/tools/llvm-objcopy/ELF/empty-section.test @@ -81,13 +81,11 @@ ProgramHeaders: - Type: PT_LOAD VAddr: 0 - PAddr: 0 Align: 0x100 Sections: - Section: .foo - Type: PT_LOAD VAddr: 0x1000 - PAddr: 0x1000 Align: 0x1000 Sections: - Section: .empty diff --git a/llvm/test/tools/llvm-objcopy/ELF/marker-segment.test b/llvm/test/tools/llvm-objcopy/ELF/marker-segment.test --- a/llvm/test/tools/llvm-objcopy/ELF/marker-segment.test +++ b/llvm/test/tools/llvm-objcopy/ELF/marker-segment.test @@ -32,26 +32,22 @@ - 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 - PAddr: 0x2000 Align: 0x1000 Sections: - Section: .data - Type: PT_GNU_STACK Flags: [ PF_R, PF_W ] VAddr: 0x0000 - PAddr: 0x0000 Align: 0x0000 - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x2010 - PAddr: 0x2010 Sections: - Section: .xdata - Section: .after diff --git a/llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test b/llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test --- a/llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test +++ b/llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test @@ -21,9 +21,9 @@ # CHECK: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align # CHECK-NEXT: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000402 0x000403 R E 0x1000 -# CHECK-NEXT: LOAD 0x000480 0x0000000000001480 0x0000000000000000 0x000000 0x00005f RW 0x1000 -# CHECK-NEXT: TLS 0x000480 0x0000000000001480 0x0000000000000000 0x000000 0x00000c RW 0x80 -# CHECK-NEXT: NOTE 0x000400 0x0000000000000400 0x0000000000000000 0x000002 0x000002 0x400 +# CHECK-NEXT: LOAD 0x000480 0x0000000000001480 0x0000000000001480 0x000000 0x00005f RW 0x1000 +# CHECK-NEXT: TLS 0x000480 0x0000000000001480 0x0000000000001480 0x000000 0x00000c RW 0x80 +# CHECK-NEXT: NOTE 0x000400 0x0000000000000400 0x0000000000000400 0x000002 0x000002 0x400 ## Contents of SHT_NOTE and .debug* are kept. @@ -136,9 +136,9 @@ ## Check that p_offset or p_filesz of empty segments or PT_PHDR are not modified. # CHECK2: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align -# CHECK2-NEXT: PHDR 0x000040 0x0000000000000040 0x0000000000000000 0x0000a8 0x0000a8 R 0x8 +# CHECK2-NEXT: PHDR 0x000040 0x0000000000000040 0x0000000000000040 0x0000a8 0x0000a8 R 0x8 # CHECK2-NEXT: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000202 0x000202 R E 0x1000 -# CHECK2-NEXT: LOAD 0x000202 0x0000000000000202 0x0000000000000000 0x00000e 0x00000e RW 0x1 +# CHECK2-NEXT: LOAD 0x000202 0x0000000000000202 0x0000000000000202 0x00000e 0x00000e RW 0x1 --- !ELF FileHeader: diff --git a/llvm/test/tools/llvm-objcopy/ELF/parent-loop-check.test b/llvm/test/tools/llvm-objcopy/ELF/parent-loop-check.test --- a/llvm/test/tools/llvm-objcopy/ELF/parent-loop-check.test +++ b/llvm/test/tools/llvm-objcopy/ELF/parent-loop-check.test @@ -36,14 +36,12 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Sections: - Section: .note - Section: .rodata - Type: PT_NOTE Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Sections: - Section: .note diff --git a/llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents.test b/llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents.test --- a/llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents.test +++ b/llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents.test @@ -313,7 +313,6 @@ # First segment has unlabelled space at start and end. - Type: 0x6ABCDEF0 # Non-specific segment type. VAddr: 0x2000 - PAddr: 0x2000 Align: 0x2000 Sections: - Section: blob1 @@ -326,7 +325,6 @@ # Second segment has sections at start and end. - Type: 0x6ABCDEF0 VAddr: 0x2100 - PAddr: 0x2100 Align: 0x100 Sections: - Section: section4 @@ -335,28 +333,24 @@ # Third segment is all covered by a section. - Type: 0x6ABCDEF0 VAddr: 0x2200 - PAddr: 0x2200 Align: 0x100 Sections: - Section: section6 # Fourth segment has no sections (after removing blob headers). - Type: 0x6ABCDEF0 VAddr: 0x2300 - PAddr: 0x2300 Align: 0x100 Sections: - Section: blob6 # Fifth segment is empty. - Type: 0x6ABCDEF0 VAddr: 0x2308 - PAddr: 0x2308 Offset: 0x2308 # The next few segments test behaviour of fully nested segments. # Sixth segment is the "parent" segment. - Type: 0x6ABCDEF0 VAddr: 0x3000 - PAddr: 0x3000 Align: 0x1000 Sections: - Section: sectionA @@ -379,24 +373,20 @@ # Seventh segment is empty and nested. - Type: 0x6ABCDEF0 VAddr: 0x3002 - PAddr: 0x3002 Offset: 0x3002 # Eighth segment contains only a section and is nested. - Type: 0x6ABCDEF0 VAddr: 0x3004 - PAddr: 0x3004 Sections: - Section: sectionB # Ninth segment contains only unlabelled space and is nested. - Type: 0x6ABCDEF0 VAddr: 0x3008 - PAddr: 0x3008 Sections: - Section: blobA # Tenth segment contains two sections with space between and is nested. - Type: 0x6ABCDEF0 VAddr: 0x300C - PAddr: 0x300C Sections: - Section: sectionC - Section: blobB @@ -404,7 +394,6 @@ # Eleventh segment contains two sections with space between and at ends and is nested. - Type: 0x6ABCDEF0 VAddr: 0x3018 - PAddr: 0x3018 Sections: - Section: blobC - Section: sectionE @@ -414,7 +403,6 @@ # Twelfth segment contains one section with space at ends adjacent to space in parent segment. - Type: 0x6ABCDEF0 VAddr: 0x302E - PAddr: 0x302E Offset: 0x302E FileSize: 8 Sections: @@ -422,7 +410,6 @@ # Thirteenth segment contains overlaps sections at either end in parent segment. - Type: 0x6ABCDEF0 VAddr: 0x303A - PAddr: 0x303A Offset: 0x303A FileSize: 0x8 Sections: @@ -434,13 +421,11 @@ # Segment15: |--|-Sec-|-unlabelled-| - Type: 0x6ABCDEF0 VAddr: 0x4000 - PAddr: 0x4000 Sections: - Section: blobz - Section: sectionz - Type: 0x6ABCDEF0 VAddr: 0x4002 - PAddr: 0x4002 Offset: 0x4002 Sections: - Section: sectionz @@ -450,13 +435,11 @@ # Segment17: |--|----unlabelled---| - Type: 0x6ABCDEF0 VAddr: 0x400C - PAddr: 0x400C FileSize: 6 Sections: - Section: sectiony - Type: 0x6ABCDEF0 VAddr: 0x400E - PAddr: 0x400E Offset: 0x400E Sections: - Section: blobx @@ -465,13 +448,11 @@ # Segment19: |-Sec-|-unlabelled-| - Type: 0x6ABCDEF0 VAddr: 0x4014 - PAddr: 0x4014 Sections: - Section: blobw - Section: sectionx - Type: 0x6ABCDEF0 VAddr: 0x4018 - PAddr: 0x4018 Sections: - Section: sectionx - Section: blobv @@ -480,12 +461,10 @@ # Segment21: |--|-unlabelled-|-Sec-| - Type: 0x6ABCDEF0 VAddr: 0x4020 - PAddr: 0x4020 Sections: - Section: sectionw - Type: 0x6ABCDEF0 VAddr: 0x4022 - PAddr: 0x4022 Offset: 0x4022 Sections: - Section: blobu @@ -495,12 +474,10 @@ # Segment23: |--|-Sec-| - Type: 0x6ABCDEF0 VAddr: 0x402C - PAddr: 0x402C Sections: - Section: sectionu - Type: 0x6ABCDEF0 VAddr: 0x402E - PAddr: 0x402E Offset: 0x402E Sections: - Section: sectiont @@ -509,13 +486,11 @@ # Segment25: |--Sec--| - Type: 0x6ABCDEF0 VAddr: 0x4034 - PAddr: 0x4034 FileSize: 6 Sections: - Section: blobt - Type: 0x6ABCDEF0 VAddr: 0x4038 - PAddr: 0x4038 Sections: - Section: sections @@ -527,7 +502,6 @@ # Segment28: |-Sec-|------------| - Type: 0x6ABCDEF0 VAddr: 0x5000 - PAddr: 0x5000 Align: 0x1000 Sections: - Section: bloba @@ -535,13 +509,11 @@ - Section: blobb - Type: 0x6ABCDEF0 VAddr: 0x5000 - PAddr: 0x5000 FileSize: 6 Sections: - Section: bloba - Type: 0x6ABCDEF0 VAddr: 0x5004 - PAddr: 0x5004 Sections: - Section: sectiona - Section: blobb @@ -551,20 +523,17 @@ # Segment31: |---------|-Sec-| - Type: 0x6ABCDEF0 VAddr: 0x500C - PAddr: 0x500C Sections: - Section: sectionb - Section: blobc - Section: sectionc - Type: 0x6ABCDEF0 VAddr: 0x500C - PAddr: 0x500C FileSize: 7 Sections: - Section: sectionb - Type: 0x6ABCDEF0 VAddr: 0x5011 - PAddr: 0x5011 Offset: 0x5011 Sections: - Section: sectionc @@ -574,20 +543,17 @@ # Segment34: |------------|-Sec-| - Type: 0x6ABCDEF0 VAddr: 0x5018 - PAddr: 0x5018 Sections: - Section: sectiond - Section: blobd - Section: sectione - Type: 0x6ABCDEF0 VAddr: 0x5018 - PAddr: 0x5018 Sections: - Section: sectiond - Section: blobd - Type: 0x6ABCDEF0 VAddr: 0x501C - PAddr: 0x501C Sections: - Section: blobd - Section: sectione @@ -597,20 +563,17 @@ # Segment37: |-Sec-|------------| - Type: 0x6ABCDEF0 VAddr: 0x5024 - PAddr: 0x5024 Sections: - Section: blobe - Section: sectionf - Section: blobf - Type: 0x6ABCDEF0 VAddr: 0x5024 - PAddr: 0x5024 Sections: - Section: blobe - Section: sectionf - Type: 0x6ABCDEF0 VAddr: 0x5028 - PAddr: 0x5028 Sections: - Section: sectionf - Section: blobf @@ -620,20 +583,17 @@ # Segment40: |---|------------| - Type: 0x6ABCDEF0 VAddr: 0x5030 - PAddr: 0x5030 Sections: - Section: blobg - Section: sectiong - Section: blobh - Type: 0x6ABCDEF0 VAddr: 0x5030 - PAddr: 0x5030 FileSize: 7 Sections: - Section: blobg - Type: 0x6ABCDEF0 VAddr: 0x5035 - PAddr: 0x5035 Offset: 0x5035 Sections: - Section: blobh diff --git a/llvm/test/tools/llvm-objcopy/ELF/segment-shift-section-remove.test b/llvm/test/tools/llvm-objcopy/ELF/segment-shift-section-remove.test --- a/llvm/test/tools/llvm-objcopy/ELF/segment-shift-section-remove.test +++ b/llvm/test/tools/llvm-objcopy/ELF/segment-shift-section-remove.test @@ -31,13 +31,11 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Sections: - Section: .text - Type: PT_LOAD Flags: [ PF_X, PF_R ] VAddr: 0x3000 - PAddr: 0x3000 Sections: - Section: .text3 ## TODO (grimar): without the following line (i.e. without an empty symbol table), diff --git a/llvm/test/tools/llvm-objcopy/ELF/segment-shift.test b/llvm/test/tools/llvm-objcopy/ELF/segment-shift.test --- a/llvm/test/tools/llvm-objcopy/ELF/segment-shift.test +++ b/llvm/test/tools/llvm-objcopy/ELF/segment-shift.test @@ -31,13 +31,11 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Sections: - Section: .text - Type: PT_LOAD Flags: [ PF_X, PF_R ] VAddr: 0x3000 - PAddr: 0x3000 Sections: - Section: .text3 diff --git a/llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-end.test b/llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-end.test --- a/llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-end.test +++ b/llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-end.test @@ -42,14 +42,12 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Sections: - Section: .text - Section: .text2 - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x3000 - PAddr: 0x3000 Sections: - Section: .text3 - Section: .text4 diff --git a/llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-first.test b/llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-first.test --- a/llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-first.test +++ b/llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-first.test @@ -42,14 +42,12 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Sections: - Section: .text - Section: .text2 - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x3000 - PAddr: 0x3000 Sections: - Section: .text3 - Section: .text4 diff --git a/llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-third-sec.test b/llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-third-sec.test --- a/llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-third-sec.test +++ b/llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-third-sec.test @@ -42,14 +42,12 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Sections: - Section: .text - Section: .text2 - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x3000 - PAddr: 0x3000 Sections: - Section: .text3 - Section: .text4 diff --git a/llvm/test/tools/llvm-objdump/X86/phdrs-lma2.test b/llvm/test/tools/llvm-objdump/X86/phdrs-lma2.test --- a/llvm/test/tools/llvm-objdump/X86/phdrs-lma2.test +++ b/llvm/test/tools/llvm-objdump/X86/phdrs-lma2.test @@ -48,13 +48,11 @@ - Type: PT_LOAD Flags: [ PF_X, PF_R ] VAddr: 0x00001000 - PAddr: 0x00001000 Sections: - Section: .text - Section: .init - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x00002000 - PAddr: 0x00002000 Sections: - Section: .data diff --git a/llvm/test/tools/llvm-readobj/ELF/demangle.test b/llvm/test/tools/llvm-readobj/ELF/demangle.test --- a/llvm/test/tools/llvm-readobj/ELF/demangle.test +++ b/llvm/test/tools/llvm-readobj/ELF/demangle.test @@ -212,7 +212,6 @@ - Type: PT_LOAD Flags: [ PF_R, PF_X ] VAddr: 0x0 - PAddr: 0x0 Sections: - Section: .dynsym - Section: .dynstr @@ -222,6 +221,5 @@ - Type: PT_DYNAMIC Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Sections: - Section: .dynamic diff --git a/llvm/test/tools/llvm-readobj/ELF/hash-symbols.test b/llvm/test/tools/llvm-readobj/ELF/hash-symbols.test --- a/llvm/test/tools/llvm-readobj/ELF/hash-symbols.test +++ b/llvm/test/tools/llvm-readobj/ELF/hash-symbols.test @@ -363,7 +363,6 @@ - Type: PT_LOAD Flags: [ PF_R, PF_X ] VAddr: 0x0 - PAddr: 0x0 Sections: - Section: .dynsym - Section: .dynstr @@ -372,7 +371,6 @@ - Type: PT_DYNAMIC Flags: [ PF_R ] VAddr: 0x1000 - PAddr: 0x1000 Sections: - Section: .dynamic diff --git a/llvm/test/tools/llvm-readobj/ELF/loadname.test b/llvm/test/tools/llvm-readobj/ELF/loadname.test --- a/llvm/test/tools/llvm-readobj/ELF/loadname.test +++ b/llvm/test/tools/llvm-readobj/ELF/loadname.test @@ -44,7 +44,6 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x0000 - PAddr: 0x0000 Sections: - Section: .dynstr - Section: .dynamic diff --git a/llvm/test/tools/yaml2obj/ELF/custom-fill.yaml b/llvm/test/tools/yaml2obj/ELF/custom-fill.yaml --- a/llvm/test/tools/yaml2obj/ELF/custom-fill.yaml +++ b/llvm/test/tools/yaml2obj/ELF/custom-fill.yaml @@ -124,14 +124,12 @@ ProgramHeaders: - Type: PT_LOAD VAddr: 0x100 - PAddr: 0x100 Sections: - Section: fill1 - Section: .bar - Section: fill2 - Type: PT_GNU_RELRO VAddr: 0x105 - PAddr: 0x105 Sections: - Section: fill2 diff --git a/llvm/test/tools/yaml2obj/ELF/dynamic-section-i386.yaml b/llvm/test/tools/yaml2obj/ELF/dynamic-section-i386.yaml --- a/llvm/test/tools/yaml2obj/ELF/dynamic-section-i386.yaml +++ b/llvm/test/tools/yaml2obj/ELF/dynamic-section-i386.yaml @@ -31,13 +31,11 @@ - Type: PT_LOAD Flags: [ PF_R ] VAddr: 0x0000 - PAddr: 0x0000 Align: 8 Sections: - Section: .dynamic - Type: PT_DYNAMIC Flags: [ PF_X, PF_R ] VAddr: 0x0008 - PAddr: 0x0008 Sections: - Section: .dynamic diff --git a/llvm/test/tools/yaml2obj/ELF/program-header-address.yaml b/llvm/test/tools/yaml2obj/ELF/program-header-address.yaml new file mode 100644 --- /dev/null +++ b/llvm/test/tools/yaml2obj/ELF/program-header-address.yaml @@ -0,0 +1,55 @@ +## Show how yaml2obj sets physical and virtual addresses of program headers. + +# RUN: yaml2obj %s -o %t +# RUN: llvm-readelf --sections --segments %t | FileCheck %s + +# CHECK: Section Headers: +# CHECK: [Nr] Name Type Address Off Size ES Flg +# CHECK: [ 1] .foo PROGBITS 0000000000001234 000120 000001 00 A + +# CHECK: Program Headers: +# CHECK-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align +# CHECK-NEXT: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 R E 0x1 +# CHECK-NEXT: LOAD 0x000120 0x0000000000000000 0x0000000000000000 0x000001 0x000001 R E 0x1 +# CHECK-NEXT: LOAD 0x000120 0x00000000aaaa1000 0x00000000aaaa1000 0x000001 0x000001 R E 0x1 +# CHECK-NEXT: LOAD 0x000120 0x00000000aaaa1000 0x00000000bbbb2000 0x000001 0x000001 R E 0x1 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .foo + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Size: 0x1 + Address: 0x1234 +ProgramHeaders: +## Show addresses we emit by default for a case when a program header +## has no sections included. + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + Sections: [] +## Show addresses we emit by default for a case when a program header +## includes a section with a virtual address that is explicitly set. + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + Sections: + - Section: .foo +## Now we have a program header that has a virtual address different from +## a address of the section included. Show that the default physical address +## is equal to virtual address. + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0xAAAA1000 + Sections: + - Section: .foo +## Show that we are able to set different virtual and physical addresses. + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + VAddr: 0xAAAA1000 + PAddr: 0xBBBB2000 + Sections: + - Section: .foo