Skip to content

Commit b236b4c

Browse files
author
Georgii Rymar
committed
[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
1 parent f47f4c1 commit b236b4c

38 files changed

+61
-109
lines changed

llvm/lib/ObjectYAML/ELFYAML.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ void MappingTraits<ELFYAML::ProgramHeader>::mapping(
848848
IO.mapOptional("Flags", Phdr.Flags, ELFYAML::ELF_PF(0));
849849
IO.mapOptional("Sections", Phdr.Sections);
850850
IO.mapOptional("VAddr", Phdr.VAddr, Hex64(0));
851-
IO.mapOptional("PAddr", Phdr.PAddr, Hex64(0));
851+
IO.mapOptional("PAddr", Phdr.PAddr, Phdr.VAddr);
852852
IO.mapOptional("Align", Phdr.Align);
853853
IO.mapOptional("FileSize", Phdr.FileSize);
854854
IO.mapOptional("MemSize", Phdr.MemSize);

llvm/test/tools/llvm-elfabi/binary-read-add-soname.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,13 @@ ProgramHeaders:
3333
- Type: PT_LOAD
3434
Flags: [ PF_R ]
3535
VAddr: 0x0000
36-
PAddr: 0x0000
3736
Align: 8
3837
Sections:
3938
- Section: .dynstr
4039
- Section: .dynamic
4140
- Type: PT_DYNAMIC
4241
Flags: [ PF_X, PF_R ]
4342
VAddr: 0x0008
44-
PAddr: 0x0008
4543
Sections:
4644
- Section: .dynamic
4745

llvm/test/tools/llvm-elfabi/binary-read-arch.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,13 @@ ProgramHeaders:
3333
- Type: PT_LOAD
3434
Flags: [ PF_R ]
3535
VAddr: 0x0000
36-
PAddr: 0x0000
3736
Align: 8
3837
Sections:
3938
- Section: .dynstr
4039
- Section: .dynamic
4140
- Type: PT_DYNAMIC
4241
Flags: [ PF_X, PF_R ]
4342
VAddr: 0x0008
44-
PAddr: 0x0008
4543
Sections:
4644
- Section: .dynamic
4745

llvm/test/tools/llvm-elfabi/binary-read-bad-soname.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,13 @@ ProgramHeaders:
3535
- Type: PT_LOAD
3636
Flags: [ PF_R ]
3737
VAddr: 0x0000
38-
PAddr: 0x0000
3938
Align: 8
4039
Sections:
4140
- Section: .dynstr
4241
- Section: .dynamic
4342
- Type: PT_DYNAMIC
4443
Flags: [ PF_X, PF_R ]
4544
VAddr: 0x0008
46-
PAddr: 0x0008
4745
Sections:
4846
- Section: .dynamic
4947

llvm/test/tools/llvm-elfabi/binary-read-bad-vaddr.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,13 @@ ProgramHeaders:
3535
- Type: PT_LOAD
3636
Flags: [ PF_R ]
3737
VAddr: 0x1000
38-
PAddr: 0x1000
3938
Align: 8
4039
Sections:
4140
- Section: .dynstr
4241
- Section: .dynamic
4342
- Type: PT_DYNAMIC
4443
Flags: [ PF_X, PF_R ]
4544
VAddr: 0x1008
46-
PAddr: 0x1008
4745
Sections:
4846
- Section: .dynamic
4947

llvm/test/tools/llvm-elfabi/binary-read-neededlibs-bad-offset.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,13 @@ ProgramHeaders:
3939
- Type: PT_LOAD
4040
Flags: [ PF_R ]
4141
VAddr: 0x1000
42-
PAddr: 0x1000
4342
Align: 8
4443
Sections:
4544
- Section: .dynstr
4645
- Section: .dynamic
4746
- Type: PT_DYNAMIC
4847
Flags: [ PF_X, PF_R ]
4948
VAddr: 0x1024
50-
PAddr: 0x1024
5149
Sections:
5250

5351
# CHECK: DT_NEEDED string offset (0x000000000000ffff) outside of dynamic string table

llvm/test/tools/llvm-elfabi/binary-read-neededlibs.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@ ProgramHeaders:
3838
- Type: PT_LOAD
3939
Flags: [ PF_R ]
4040
VAddr: 0x1000
41-
PAddr: 0x1000
4241
Align: 8
4342
Sections:
4443
- Section: .dynstr
4544
- Section: .dynamic
4645
- Type: PT_DYNAMIC
4746
Flags: [ PF_X, PF_R ]
4847
VAddr: 0x1024
49-
PAddr: 0x1024
5048
Sections:
5149

5250
# CHECK: NeededLibs:

llvm/test/tools/llvm-elfabi/binary-read-no-dt-strsz.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@ ProgramHeaders:
3030
- Type: PT_LOAD
3131
Flags: [ PF_R ]
3232
VAddr: 0x0000
33-
PAddr: 0x0000
3433
Align: 8
3534
Sections:
3635
- Section: .dynstr
3736
- Section: .dynamic
3837
- Type: PT_DYNAMIC
3938
Flags: [ PF_X, PF_R ]
4039
VAddr: 0x0008
41-
PAddr: 0x0008
4240
Sections:
4341
- Section: .dynamic
4442

llvm/test/tools/llvm-elfabi/binary-read-no-dt-strtab.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ ProgramHeaders:
2929
- Type: PT_LOAD
3030
Flags: [ PF_R ]
3131
VAddr: 0x0000
32-
PAddr: 0x0000
3332
Align: 8
3433
Sections:
3534
- Section: .dynstr
3635
- Section: .dynamic
3736
- Type: PT_DYNAMIC
3837
Flags: [ PF_X, PF_R ]
3938
VAddr: 0x0008
40-
PAddr: 0x0008
4139
Sections:
4240
- Section: .dynamic
4341

llvm/test/tools/llvm-elfabi/binary-read-replace-soname.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,13 @@ ProgramHeaders:
3737
- Type: PT_LOAD
3838
Flags: [ PF_R ]
3939
VAddr: 0x1000
40-
PAddr: 0x1000
4140
Align: 8
4241
Sections:
4342
- Section: .dynstr
4443
- Section: .dynamic
4544
- Type: PT_DYNAMIC
4645
Flags: [ PF_X, PF_R ]
4746
VAddr: 0x1018
48-
PAddr: 0x1018
4947
Sections:
5048
- Section: .dynamic
5149

llvm/test/tools/llvm-elfabi/binary-read-soname-no-null.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@ ProgramHeaders:
3636
- Type: PT_LOAD
3737
Flags: [ PF_R ]
3838
VAddr: 0x1000
39-
PAddr: 0x1000
4039
Align: 8
4140
Sections:
4241
- Section: .dynstr
4342
- Section: .dynamic
4443
- Type: PT_DYNAMIC
4544
Flags: [ PF_X, PF_R ]
4645
VAddr: 0x1018
47-
PAddr: 0x1018
4846
Sections:
4947
- Section: .dynamic
5048

llvm/test/tools/llvm-elfabi/binary-read-soname.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@ ProgramHeaders:
3636
- Type: PT_LOAD
3737
Flags: [ PF_R ]
3838
VAddr: 0x1000
39-
PAddr: 0x1000
4039
Align: 8
4140
Sections:
4241
- Section: .dynstr
4342
- Section: .dynamic
4443
- Type: PT_DYNAMIC
4544
Flags: [ PF_X, PF_R ]
4645
VAddr: 0x1018
47-
PAddr: 0x1018
4846
Sections:
4947
- Section: .dynamic
5048

llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ ProgramHeaders:
388388
- Type: PT_LOAD
389389
Flags: [ PF_X, PF_R ]
390390
VAddr: 0x0000000000400000
391-
PAddr: 0x0000000000400000
392391
Align: 1024
393392
Sections:
394393
- Section: .interp

llvm/test/tools/llvm-objcopy/ELF/add-symbol.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,12 @@ ProgramHeaders:
4747
- Type: PT_LOAD
4848
Flags: [ PF_X, PF_R ]
4949
VAddr: 0x1000
50-
PAddr: 0x1000
5150
Align: 0x1000
5251
Sections:
5352
- Section: .text
5453
- Type: PT_LOAD
5554
Flags: [ PF_R, PF_W ]
5655
VAddr: 0x2000
57-
PAddr: 0x2000
5856
Align: 0x1000
5957
Sections:
6058
- Section: .data

llvm/test/tools/llvm-objcopy/ELF/binary-first-seg-offset-zero.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ ProgramHeaders:
2626
- Type: PT_LOAD
2727
Flags: [ PF_R ]
2828
VAddr: 0x1000
29-
PAddr: 0x1000
3029
Sections:
3130
- Section: .note
3231
- Section: .rodata

llvm/test/tools/llvm-objcopy/ELF/binary-paddr.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,5 @@ ProgramHeaders:
127127
- Type: PT_LOAD
128128
Flags: [ PF_R, PF_W ]
129129
VAddr: 0x3000
130-
PAddr: 0x3000
131130
Sections:
132131
- Section: .data

llvm/test/tools/llvm-objcopy/ELF/binary-remove-all-but-one.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ ProgramHeaders:
3535
- Type: PT_LOAD
3636
Flags: [ PF_R ]
3737
VAddr: 0x1000
38-
PAddr: 0x1000
3938
Sections:
4039
- Section: .text
4140
- Section: .text2

llvm/test/tools/llvm-objcopy/ELF/binary-remove-end.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ ProgramHeaders:
3535
- Type: PT_LOAD
3636
Flags: [ PF_R ]
3737
VAddr: 0x1000
38-
PAddr: 0x1000
3938
Sections:
4039
- Section: .text
4140
- Section: .text2

llvm/test/tools/llvm-objcopy/ELF/binary-remove-middle.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ ProgramHeaders:
3535
- Type: PT_LOAD
3636
Flags: [ PF_R ]
3737
VAddr: 0x1000
38-
PAddr: 0x1000
3938
Sections:
4039
- Section: .text
4140
- Section: .text2

llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align-binary.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ ProgramHeaders:
2525
- Type: PT_LOAD
2626
Flags: [ PF_X, PF_R ]
2727
VAddr: 0x1000
28-
PAddr: 0x1000
2928
Align: 0x1000
3029
Sections:
3130
- Section: .text
3231
- Type: PT_LOAD
3332
Flags: [ PF_R, PF_W ]
3433
VAddr: 0x1008
35-
PAddr: 0x1008
3634
Align: 0x1000
3735
Sections:
3836
- Section: .data

llvm/test/tools/llvm-objcopy/ELF/check-addr-offset-align.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ ProgramHeaders:
2525
- Type: PT_LOAD
2626
Flags: [ PF_X, PF_R ]
2727
VAddr: 0x1000
28-
PAddr: 0x1000
2928
Align: 0x1000
3029
Sections:
3130
- Section: .text
3231
- Type: PT_LOAD
3332
Flags: [ PF_R, PF_W ]
3433
VAddr: 0x1008
35-
PAddr: 0x1008
3634
Align: 0x1000
3735
Sections:
3836
- Section: .data

llvm/test/tools/llvm-objcopy/ELF/empty-section.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,11 @@ Sections:
8181
ProgramHeaders:
8282
- Type: PT_LOAD
8383
VAddr: 0
84-
PAddr: 0
8584
Align: 0x100
8685
Sections:
8786
- Section: .foo
8887
- Type: PT_LOAD
8988
VAddr: 0x1000
90-
PAddr: 0x1000
9189
Align: 0x1000
9290
Sections:
9391
- Section: .empty

llvm/test/tools/llvm-objcopy/ELF/marker-segment.test

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,22 @@ ProgramHeaders:
3232
- Type: PT_LOAD
3333
Flags: [ PF_X, PF_R ]
3434
VAddr: 0x1000
35-
PAddr: 0x1000
3635
Align: 0x1000
3736
Sections:
3837
- Section: .text
3938
- Type: PT_LOAD
4039
Flags: [ PF_R, PF_W ]
4140
VAddr: 0x2000
42-
PAddr: 0x2000
4341
Align: 0x1000
4442
Sections:
4543
- Section: .data
4644
- Type: PT_GNU_STACK
4745
Flags: [ PF_R, PF_W ]
4846
VAddr: 0x0000
49-
PAddr: 0x0000
5047
Align: 0x0000
5148
- Type: PT_LOAD
5249
Flags: [ PF_R ]
5350
VAddr: 0x2010
54-
PAddr: 0x2010
5551
Sections:
5652
- Section: .xdata
5753
- Section: .after

llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
# CHECK: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
2323
# CHECK-NEXT: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000402 0x000403 R E 0x1000
24-
# CHECK-NEXT: LOAD 0x000480 0x0000000000001480 0x0000000000000000 0x000000 0x00005f RW 0x1000
25-
# CHECK-NEXT: TLS 0x000480 0x0000000000001480 0x0000000000000000 0x000000 0x00000c RW 0x80
26-
# CHECK-NEXT: NOTE 0x000400 0x0000000000000400 0x0000000000000000 0x000002 0x000002 0x400
24+
# CHECK-NEXT: LOAD 0x000480 0x0000000000001480 0x0000000000001480 0x000000 0x00005f RW 0x1000
25+
# CHECK-NEXT: TLS 0x000480 0x0000000000001480 0x0000000000001480 0x000000 0x00000c RW 0x80
26+
# CHECK-NEXT: NOTE 0x000400 0x0000000000000400 0x0000000000000400 0x000002 0x000002 0x400
2727

2828
## Contents of SHT_NOTE and .debug* are kept.
2929

@@ -136,9 +136,9 @@ ProgramHeaders:
136136

137137
## Check that p_offset or p_filesz of empty segments or PT_PHDR are not modified.
138138
# CHECK2: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
139-
# CHECK2-NEXT: PHDR 0x000040 0x0000000000000040 0x0000000000000000 0x0000a8 0x0000a8 R 0x8
139+
# CHECK2-NEXT: PHDR 0x000040 0x0000000000000040 0x0000000000000040 0x0000a8 0x0000a8 R 0x8
140140
# CHECK2-NEXT: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000202 0x000202 R E 0x1000
141-
# CHECK2-NEXT: LOAD 0x000202 0x0000000000000202 0x0000000000000000 0x00000e 0x00000e RW 0x1
141+
# CHECK2-NEXT: LOAD 0x000202 0x0000000000000202 0x0000000000000202 0x00000e 0x00000e RW 0x1
142142

143143
--- !ELF
144144
FileHeader:

llvm/test/tools/llvm-objcopy/ELF/parent-loop-check.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ ProgramHeaders:
3636
- Type: PT_LOAD
3737
Flags: [ PF_R ]
3838
VAddr: 0x1000
39-
PAddr: 0x1000
4039
Sections:
4140
- Section: .note
4241
- Section: .rodata
4342
- Type: PT_NOTE
4443
Flags: [ PF_R ]
4544
VAddr: 0x1000
46-
PAddr: 0x1000
4745
Sections:
4846
- Section: .note
4947

0 commit comments

Comments
 (0)