[llvm] b236b4c - [yaml2obj] - Set a default value for `PAddr` property of a program header to a value of `VAddr`

Georgii Rymar via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 14 07:56:22 PDT 2020


Author: Georgii Rymar
Date: 2020-03-14T17:44:57+03:00
New Revision: b236b4cb430674a98917ad1b2fa9f7f9838e66f1

URL: https://github.com/llvm/llvm-project/commit/b236b4cb430674a98917ad1b2fa9f7f9838e66f1
DIFF: https://github.com/llvm/llvm-project/commit/b236b4cb430674a98917ad1b2fa9f7f9838e66f1.diff

LOG: [yaml2obj] - Set a default value for `PAddr` property of a program header to a value of `VAddr`

`PAddr` corresponds to `p_paddr` of a program header, which is the segment's physical
address for systems in which physical addressing is relevant. `p_paddr` is often equal
to `p_vaddr`, which is the virtual address of a segment.

This patch changes the default for `PAddr` from 0 to a value of `VAddr`.

Differential revision: https://reviews.llvm.org/D76131

Added: 
    llvm/test/tools/yaml2obj/ELF/program-header-address.yaml

Modified: 
    llvm/lib/ObjectYAML/ELFYAML.cpp
    llvm/test/tools/llvm-elfabi/binary-read-add-soname.test
    llvm/test/tools/llvm-elfabi/binary-read-arch.test
    llvm/test/tools/llvm-elfabi/binary-read-bad-soname.test
    llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test
    llvm/test/tools/llvm-elfabi/binary-read-neededlibs-bad-offset.test
    llvm/test/tools/llvm-elfabi/binary-read-neededlibs.test
    llvm/test/tools/llvm-elfabi/binary-read-no-dt-strsz.test
    llvm/test/tools/llvm-elfabi/binary-read-no-dt-strtab.test
    llvm/test/tools/llvm-elfabi/binary-read-replace-soname.test
    llvm/test/tools/llvm-elfabi/binary-read-soname-no-null.test
    llvm/test/tools/llvm-elfabi/binary-read-soname.test
    llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml
    llvm/test/tools/llvm-objcopy/ELF/add-symbol.test
    llvm/test/tools/llvm-objcopy/ELF/binary-first-seg-offset-zero.test
    llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test
    llvm/test/tools/llvm-objcopy/ELF/binary-remove-all-but-one.test
    llvm/test/tools/llvm-objcopy/ELF/binary-remove-end.test
    llvm/test/tools/llvm-objcopy/ELF/binary-remove-middle.test
    llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align-binary.test
    llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align.test
    llvm/test/tools/llvm-objcopy/ELF/empty-section.test
    llvm/test/tools/llvm-objcopy/ELF/marker-segment.test
    llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test
    llvm/test/tools/llvm-objcopy/ELF/parent-loop-check.test
    llvm/test/tools/llvm-objcopy/ELF/preserve-segment-contents.test
    llvm/test/tools/llvm-objcopy/ELF/segment-shift-section-remove.test
    llvm/test/tools/llvm-objcopy/ELF/segment-shift.test
    llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-end.test
    llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-first.test
    llvm/test/tools/llvm-objcopy/ELF/two-seg-remove-third-sec.test
    llvm/test/tools/llvm-objdump/X86/phdrs-lma2.test
    llvm/test/tools/llvm-readobj/ELF/demangle.test
    llvm/test/tools/llvm-readobj/ELF/hash-symbols.test
    llvm/test/tools/llvm-readobj/ELF/loadname.test
    llvm/test/tools/yaml2obj/ELF/custom-fill.yaml
    llvm/test/tools/yaml2obj/ELF/dynamic-section-i386.yaml

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index 55589a91d8f4..d567153af4c2 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -848,7 +848,7 @@ void MappingTraits<ELFYAML::ProgramHeader>::mapping(
   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
index e5d0860199d7..6539178f7651 100644
--- 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 @@ ProgramHeaders:
   - Type: PT_LOAD
     Flags: [ PF_R ]
     VAddr: 0x0000
-    PAddr: 0x0000
     Align: 8
     Sections:
       - Section: .dynstr
@@ -41,7 +40,6 @@ ProgramHeaders:
   - 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
index 1fea6ebbeaf6..84c331bc2f30 100644
--- a/llvm/test/tools/llvm-elfabi/binary-read-arch.test
+++ b/llvm/test/tools/llvm-elfabi/binary-read-arch.test
@@ -33,7 +33,6 @@ ProgramHeaders:
   - Type: PT_LOAD
     Flags: [ PF_R ]
     VAddr: 0x0000
-    PAddr: 0x0000
     Align: 8
     Sections:
       - Section: .dynstr
@@ -41,7 +40,6 @@ ProgramHeaders:
   - 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
index 0a1f9d931c17..e555c6f38e92 100644
--- 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 @@ ProgramHeaders:
   - Type: PT_LOAD
     Flags: [ PF_R ]
     VAddr: 0x0000
-    PAddr: 0x0000
     Align: 8
     Sections:
       - Section: .dynstr
@@ -43,7 +42,6 @@ ProgramHeaders:
   - 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
index dfdc0e6ade63..fa713051166f 100644
--- 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 @@ ProgramHeaders:
   - Type: PT_LOAD
     Flags: [ PF_R ]
     VAddr: 0x1000
-    PAddr: 0x1000
     Align: 8
     Sections:
       - Section: .dynstr
@@ -43,7 +42,6 @@ ProgramHeaders:
   - 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
index bb832210df93..2acdf5b55ec8 100644
--- 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 @@ ProgramHeaders:
   - Type: PT_LOAD
     Flags: [ PF_R ]
     VAddr: 0x1000
-    PAddr: 0x1000
     Align: 8
     Sections:
       - Section: .dynstr
@@ -47,7 +46,6 @@ ProgramHeaders:
   - 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
index 09567e00e359..8914cae85491 100644
--- a/llvm/test/tools/llvm-elfabi/binary-read-neededlibs.test
+++ b/llvm/test/tools/llvm-elfabi/binary-read-neededlibs.test
@@ -38,7 +38,6 @@ ProgramHeaders:
   - Type: PT_LOAD
     Flags: [ PF_R ]
     VAddr: 0x1000
-    PAddr: 0x1000
     Align: 8
     Sections:
       - Section: .dynstr
@@ -46,7 +45,6 @@ ProgramHeaders:
   - 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
index cf4561e0e270..643b814feda9 100644
--- 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 @@ ProgramHeaders:
   - Type: PT_LOAD
     Flags: [ PF_R ]
     VAddr: 0x0000
-    PAddr: 0x0000
     Align: 8
     Sections:
       - Section: .dynstr
@@ -38,7 +37,6 @@ ProgramHeaders:
   - 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
index 315aae3bda84..699c60c298eb 100644
--- 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 @@ ProgramHeaders:
   - Type: PT_LOAD
     Flags: [ PF_R ]
     VAddr: 0x0000
-    PAddr: 0x0000
     Align: 8
     Sections:
       - Section: .dynstr
@@ -37,7 +36,6 @@ ProgramHeaders:
   - 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
index 4e6c1f7cb568..c8e592f9baaf 100644
--- 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 @@ ProgramHeaders:
   - Type: PT_LOAD
     Flags: [ PF_R ]
     VAddr: 0x1000
-    PAddr: 0x1000
     Align: 8
     Sections:
       - Section: .dynstr
@@ -45,7 +44,6 @@ ProgramHeaders:
   - 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
index 099b5741f769..8c499c942941 100644
--- 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 @@ ProgramHeaders:
   - Type: PT_LOAD
     Flags: [ PF_R ]
     VAddr: 0x1000
-    PAddr: 0x1000
     Align: 8
     Sections:
       - Section: .dynstr
@@ -44,7 +43,6 @@ ProgramHeaders:
   - 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
index 960cc65b6dd1..5b67ada5848d 100644
--- a/llvm/test/tools/llvm-elfabi/binary-read-soname.test
+++ b/llvm/test/tools/llvm-elfabi/binary-read-soname.test
@@ -36,7 +36,6 @@ ProgramHeaders:
   - Type: PT_LOAD
     Flags: [ PF_R ]
     VAddr: 0x1000
-    PAddr: 0x1000
     Align: 8
     Sections:
       - Section: .dynstr
@@ -44,7 +43,6 @@ ProgramHeaders:
   - 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
index fe696e42fab4..0fb56a5b2e01 100644
--- a/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml
+++ b/llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml
@@ -388,7 +388,6 @@ ProgramHeaders:
   - 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
index a9002d429712..8950894d5078 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/add-symbol.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/add-symbol.test
@@ -47,14 +47,12 @@ 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
-    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
index 2f04d64a2c36..9af417f245f0 100644
--- 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 @@ ProgramHeaders:
   - 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
index 5ac692dc5f86..fd78d436930d 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test
@@ -127,6 +127,5 @@ ProgramHeaders:
   - 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
index 857b76d9a2f3..1336b7d93951 100644
--- 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 @@ ProgramHeaders:
   - 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
index eddeaf167ec3..d9f27526dfb7 100644
--- 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 @@ ProgramHeaders:
   - 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
index fbc2f6a9ee37..4ed3ca65934f 100644
--- 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 @@ ProgramHeaders:
   - 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
index 6d4cb1b41dda..c36f812bdb8b 100644
--- 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 @@ 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: 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
index bc219fff7839..54c65ce4736d 100644
--- 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 @@ 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: 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
index 3ad1b7cae39c..25c6c45d5528 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/empty-section.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/empty-section.test
@@ -81,13 +81,11 @@ Sections:
 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
index 548def4334ac..f52f9fbe7f98 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/marker-segment.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/marker-segment.test
@@ -32,26 +32,22 @@ 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
-    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
index 8f21bce57823..4d202ed56781 100644
--- 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 @@ ProgramHeaders:
 
 ## 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
index b3b48c935e4b..bdd82af2058f 100644
--- 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 @@ ProgramHeaders:
   - 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
index f54e83204cf3..5555a42c5a22 100644
--- 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # Second segment has sections at start and end.
   - Type:  0x6ABCDEF0
     VAddr: 0x2100
-    PAddr: 0x2100
     Align: 0x100
     Sections:
       - Section: section4
@@ -335,28 +333,24 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # Segment28:              |-Sec-|------------|
   - Type:  0x6ABCDEF0
     VAddr: 0x5000
-    PAddr: 0x5000
     Align: 0x1000
     Sections:
       - Section: bloba
@@ -535,13 +509,11 @@ ProgramHeaders:
       - 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # 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 @@ ProgramHeaders:
   # 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
index 9a50a10bc249..7a9f4cdd42b8 100644
--- 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 @@ ProgramHeaders:
   - 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
index b4caa197aec4..303edaf7a1d3 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/segment-shift.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/segment-shift.test
@@ -31,13 +31,11 @@ ProgramHeaders:
   - 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
index 20c2689ec88a..2ad3a761a9a8 100644
--- 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 @@ ProgramHeaders:
   - 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
index a541fc691555..6b58363ad250 100644
--- 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 @@ ProgramHeaders:
   - 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
index 254273d55e7e..54eef2690ba5 100644
--- 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 @@ ProgramHeaders:
   - 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
index ead250e8cf39..a8f3e2ca6157 100644
--- a/llvm/test/tools/llvm-objdump/X86/phdrs-lma2.test
+++ b/llvm/test/tools/llvm-objdump/X86/phdrs-lma2.test
@@ -48,13 +48,11 @@ ProgramHeaders:
   - 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
index 230ba9209333..46ea48f147c9 100644
--- a/llvm/test/tools/llvm-readobj/ELF/demangle.test
+++ b/llvm/test/tools/llvm-readobj/ELF/demangle.test
@@ -212,7 +212,6 @@ ProgramHeaders:
   - Type:  PT_LOAD
     Flags: [ PF_R, PF_X ]
     VAddr: 0x0
-    PAddr: 0x0
     Sections:
       - Section: .dynsym
       - Section: .dynstr
@@ -222,6 +221,5 @@ ProgramHeaders:
   - 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
index e4515b692eb5..0348444b8222 100644
--- a/llvm/test/tools/llvm-readobj/ELF/hash-symbols.test
+++ b/llvm/test/tools/llvm-readobj/ELF/hash-symbols.test
@@ -363,7 +363,6 @@ ProgramHeaders:
   - Type:  PT_LOAD
     Flags: [ PF_R, PF_X ]
     VAddr: 0x0
-    PAddr: 0x0
     Sections:
       - Section: .dynsym
       - Section: .dynstr
@@ -372,7 +371,6 @@ ProgramHeaders:
   - 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
index d12076fd46c6..c29ee33ae7e6 100644
--- a/llvm/test/tools/llvm-readobj/ELF/loadname.test
+++ b/llvm/test/tools/llvm-readobj/ELF/loadname.test
@@ -44,7 +44,6 @@ ProgramHeaders:
   - 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
index 8dfc2fdae3c2..4d7b91d6727a 100644
--- a/llvm/test/tools/yaml2obj/ELF/custom-fill.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/custom-fill.yaml
@@ -124,14 +124,12 @@ Sections:
 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
index 89f7de6fd765..4d9d5e4db4f3 100644
--- a/llvm/test/tools/yaml2obj/ELF/dynamic-section-i386.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/dynamic-section-i386.yaml
@@ -31,13 +31,11 @@ ProgramHeaders:
   - 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
index 000000000000..a1e5460e2972
--- /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 
diff erent 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 
diff erent virtual and physical addresses.
+  - Type:  PT_LOAD
+    Flags: [ PF_X, PF_R ]
+    VAddr: 0xAAAA1000
+    PAddr: 0xBBBB2000
+    Sections:
+      - Section: .foo


        


More information about the llvm-commits mailing list