diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2018-12-14 04:55:08 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2018-12-14 04:55:34 -0800 |
commit | 0a59decbb81676ac30deede1bb6b6e241cd75502 (patch) | |
tree | b5ca2b75f655add59aa82a500a86e3a511c081b1 /ld/testsuite/ld-i386 | |
parent | 0681fa5ee5a1059b9415c4b0408030fd25bd26dd (diff) | |
download | gdb-0a59decbb81676ac30deede1bb6b6e241cd75502.zip gdb-0a59decbb81676ac30deede1bb6b6e241cd75502.tar.gz gdb-0a59decbb81676ac30deede1bb6b6e241cd75502.tar.bz2 |
elf: Add PT_GNU_PROPERTY segment type
Linkers group input note sections with the same name into one output
note section with the same name. One output note section is placed in
one PT_NOTE segment. New linkers merge all input .note.gnu.property
sections into one output .note.gnu.property section with a single
NT_GNU_PROPERTY_TYPE_0 note in a single PT_NOTE segment. Since older
linkers treat input .note.gnu.property section as a generic note section
and just concatenate all input .note.gnu.property sections into one
output .note.gnu.property section without merging them, we may
see one or more NT_GNU_PROPERTY_TYPE_0 notes in PT_NOTE segment, which
are invalid.
GNU_PROPERTY_X86_UINT32_VALID was defined to address this issue such
that linker sets the bit for non-relocatable outputs. But it isn't
sufficient:
1. It doesn't cover generic properties.
2. When -mx86-used-note=yes is passed to x86 assembler, the
GNU_PROPERTY_X86_UINT32_VALID bit is set in GNU_PROPERTY_X86_ISA_1_USED
property in object file and older linkers generate invalid
NT_GNU_PROPERTY_TYPE_0 notes with the GNU_PROPERTY_X86_UINT32_VALID bit
set.
I am proposing the following changes:
1. Add PT_GNU_PROPERTY segment type:
# define PT_GNU_PROPERTY (PT_LOOS + 0x474e553)
which covers .note.gnu.property section.
2. Remove GNU_PROPERTY_X86_UINT32_VALID.
bfd/
PR ld/23900
* elf.c (get_program_header_size): Add a PT_GNU_PROPERTY
segment for NOTE_GNU_PROPERTY_SECTION_NAME.
(_bfd_elf_map_sections_to_segments): Create a PT_GNU_PROPERTY
segment for NOTE_GNU_PROPERTY_SECTION_NAME.
* elfxx-x86.c (_bfd_elf_link_setup_gnu_properties): Don't set
GNU_PROPERTY_X86_UINT32_VALID.
binutils/
PR ld/23900
* readelf.c (get_segment_type): Support PT_GNU_PROPERTY.
(decode_x86_isa): Don't check GNU_PROPERTY_X86_UINT32_VALID.
(decode_x86_feature_1): Likewise.
(decode_x86_feature_2): Likewise.
(print_gnu_property_note): Remove GNU_PROPERTY_X86_UINT32_VALID
check.
* testsuite/binutils-all/i386/empty.d: Updated.
* testsuite/binutils-all/x86-64/empty-x32.d: Likewise.
* testsuite/binutils-all/x86-64/empty.d: Likewise.
* testsuite/binutils-all/i386/pr21231b.s: Change
GNU_PROPERTY_X86_ISA_1_USED bits to 0x7fffffff.
* testsuite/binutils-all/x86-64/pr21231b.s: Likewise.
gas/
PR ld/23900
* config/tc-i386.c (x86_cleanup): Don't set
GNU_PROPERTY_X86_UINT32_VALID.
* testsuite/gas/i386/property-1.s: Change
GNU_PROPERTY_X86_ISA_1_USED bits to 0.
include/
PR ld/23900
* elf/common.h (PT_GNU_PROPERTY): New.
(GNU_PROPERTY_X86_UINT32_VALID): Removed.
ld/
PR ld/23900
* testsuite/ld-elf/elf.exp: Run PR ld/23900 test.
* testsuite/ld-elf/pr23900-1-32.rd: New file.
* testsuite/ld-elf/pr23900-1-64.rd: Likewise.
* testsuite/ld-elf/pr23900-1.d: Likewise.
* testsuite/ld-elf/pr23900-1.s: Likewise.
* testsuite/ld-elf/pr23900-2.s: Likewise.
* testsuite/ld-elf/pr23900-2a.d: Likewise.
* testsuite/ld-elf/pr23900-2b.d: Likewise.
* testsuite/ld-i386/ibt-plt-1.d: Adjusted.
* testsuite/ld-i386/ibt-plt-2c.d: Likewise.
* testsuite/ld-i386/ibt-plt-2d.d: Likewise.
* testsuite/ld-i386/ibt-plt-3d.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-1.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2c.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2d-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2c.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3c.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3d.d: Likewise.
* testsuite/ld-i386/pr23372c.d: Expect <None>
for GNU_PROPERTY_X86_ISA_1_USED.
* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
* testsuite/ld-x86-64/pr23372c.d: Likewise.
* testsuite/ld-x86-64/pr23372d-x32.d: Likewise.
* testsuite/ld-x86-64/pr23372d.d: Likewise.
* testsuite/ld-x86-64/property-x86-5a.s: Change
GNU_PROPERTY_X86_ISA_1_USED bits to 0.
* testsuite/ld-x86-64/property-x86-5b.s: Likewise.
Diffstat (limited to 'ld/testsuite/ld-i386')
-rw-r--r-- | ld/testsuite/ld-i386/ibt-plt-1.d | 22 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/ibt-plt-2c.d | 22 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/ibt-plt-2d.d | 20 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/ibt-plt-3d.d | 20 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/pr23372c.d | 2 |
5 files changed, 43 insertions, 43 deletions
diff --git a/ld/testsuite/ld-i386/ibt-plt-1.d b/ld/testsuite/ld-i386/ibt-plt-1.d index 2a8e043..beccbf7 100644 --- a/ld/testsuite/ld-i386/ibt-plt-1.d +++ b/ld/testsuite/ld-i386/ibt-plt-1.d @@ -7,45 +7,45 @@ Disassembly of section .plt: -0+160 <.plt>: +[a-f0-9]+ <.plt>: +[a-f0-9]+: ff b3 04 00 00 00 pushl 0x4\(%ebx\) +[a-f0-9]+: ff a3 08 00 00 00 jmp \*0x8\(%ebx\) +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%eax\) +[a-f0-9]+: f3 0f 1e fb endbr32 +[a-f0-9]+: 68 00 00 00 00 push \$0x0 - +[a-f0-9]+: e9 e2 ff ff ff jmp 160 <.plt> + +[a-f0-9]+: e9 e2 ff ff ff jmp [a-f0-9]+ <.plt> +[a-f0-9]+: 66 90 xchg %ax,%ax +[a-f0-9]+: f3 0f 1e fb endbr32 +[a-f0-9]+: 68 08 00 00 00 push \$0x8 - +[a-f0-9]+: e9 d2 ff ff ff jmp 160 <.plt> + +[a-f0-9]+: e9 d2 ff ff ff jmp [a-f0-9]+ <.plt> +[a-f0-9]+: 66 90 xchg %ax,%ax Disassembly of section .plt.sec: -0+190 <bar1@plt>: +[a-f0-9]+ <bar1@plt>: +[a-f0-9]+: f3 0f 1e fb endbr32 +[a-f0-9]+: ff a3 0c 00 00 00 jmp \*0xc\(%ebx\) +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\) -0+1a0 <bar2@plt>: +[a-f0-9]+ <bar2@plt>: +[a-f0-9]+: f3 0f 1e fb endbr32 +[a-f0-9]+: ff a3 10 00 00 00 jmp \*0x10\(%ebx\) +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\) Disassembly of section .text: -0+1b0 <foo>: +[a-f0-9]+ <foo>: +[a-f0-9]+: 53 push %ebx - +[a-f0-9]+: e8 18 00 00 00 call 1ce <__x86.get_pc_thunk.bx> - +[a-f0-9]+: 81 c3 36 11 00 00 add \$0x1136,%ebx + +[a-f0-9]+: e8 18 00 00 00 call [a-f0-9]+ <__x86.get_pc_thunk.bx> + +[a-f0-9]+: 81 c3 ([0-9a-f]{2} ){4}[ ]+add \$0x[a-f0-9]+,%ebx +[a-f0-9]+: 83 ec 08 sub \$0x8,%esp - +[a-f0-9]+: e8 dc ff ff ff call 1a0 <bar2@plt> - +[a-f0-9]+: e8 c7 ff ff ff call 190 <bar1@plt> + +[a-f0-9]+: e8 dc ff ff ff call [a-f0-9]+ <bar2@plt> + +[a-f0-9]+: e8 c7 ff ff ff call [a-f0-9]+ <bar1@plt> +[a-f0-9]+: 83 c4 08 add \$0x8,%esp +[a-f0-9]+: 5b pop %ebx +[a-f0-9]+: c3 ret -0+1ce <__x86.get_pc_thunk.bx>: +[a-f0-9]+ <__x86.get_pc_thunk.bx>: +[a-f0-9]+: 8b 1c 24 mov \(%esp\),%ebx +[a-f0-9]+: c3 ret #pass diff --git a/ld/testsuite/ld-i386/ibt-plt-2c.d b/ld/testsuite/ld-i386/ibt-plt-2c.d index d71f34d..7193034 100644 --- a/ld/testsuite/ld-i386/ibt-plt-2c.d +++ b/ld/testsuite/ld-i386/ibt-plt-2c.d @@ -8,45 +8,45 @@ Disassembly of section .plt: -0+160 <.plt>: +[a-f0-9]+ <.plt>: +[a-f0-9]+: ff b3 04 00 00 00 pushl 0x4\(%ebx\) +[a-f0-9]+: ff a3 08 00 00 00 jmp \*0x8\(%ebx\) +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%eax\) +[a-f0-9]+: f3 0f 1e fb endbr32 +[a-f0-9]+: 68 00 00 00 00 push \$0x0 - +[a-f0-9]+: e9 e2 ff ff ff jmp 160 <.plt> + +[a-f0-9]+: e9 e2 ff ff ff jmp [a-f0-9]+ <.plt> +[a-f0-9]+: 66 90 xchg %ax,%ax +[a-f0-9]+: f3 0f 1e fb endbr32 +[a-f0-9]+: 68 08 00 00 00 push \$0x8 - +[a-f0-9]+: e9 d2 ff ff ff jmp 160 <.plt> + +[a-f0-9]+: e9 d2 ff ff ff jmp [a-f0-9]+ <.plt> +[a-f0-9]+: 66 90 xchg %ax,%ax Disassembly of section .plt.sec: -0+190 <bar1@plt>: +[a-f0-9]+ <bar1@plt>: +[a-f0-9]+: f3 0f 1e fb endbr32 +[a-f0-9]+: ff a3 0c 00 00 00 jmp \*0xc\(%ebx\) +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\) -0+1a0 <bar2@plt>: +[a-f0-9]+ <bar2@plt>: +[a-f0-9]+: f3 0f 1e fb endbr32 +[a-f0-9]+: ff a3 10 00 00 00 jmp \*0x10\(%ebx\) +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\) Disassembly of section .text: -0+1b0 <foo>: +[a-f0-9]+ <foo>: +[a-f0-9]+: 53 push %ebx - +[a-f0-9]+: e8 18 00 00 00 call 1ce <__x86.get_pc_thunk.bx> - +[a-f0-9]+: 81 c3 36 11 00 00 add \$0x1136,%ebx + +[a-f0-9]+: e8 18 00 00 00 call [0-9a-f]+ <__x86.get_pc_thunk.bx> + +[a-f0-9]+: 81 c3 ([0-9a-f]{2} ){4}[ ]+add \$0x[a-f0-9]+,%ebx +[a-f0-9]+: 83 ec 08 sub \$0x8,%esp - +[a-f0-9]+: e8 dc ff ff ff call 1a0 <bar2@plt> - +[a-f0-9]+: e8 c7 ff ff ff call 190 <bar1@plt> + +[a-f0-9]+: e8 dc ff ff ff call [a-f0-9]+ <bar2@plt> + +[a-f0-9]+: e8 c7 ff ff ff call [a-f0-9]+ <bar1@plt> +[a-f0-9]+: 83 c4 08 add \$0x8,%esp +[a-f0-9]+: 5b pop %ebx +[a-f0-9]+: c3 ret -0+1ce <__x86.get_pc_thunk.bx>: +[a-f0-9]+ <__x86.get_pc_thunk.bx>: +[a-f0-9]+: 8b 1c 24 mov \(%esp\),%ebx +[a-f0-9]+: c3 ret #pass diff --git a/ld/testsuite/ld-i386/ibt-plt-2d.d b/ld/testsuite/ld-i386/ibt-plt-2d.d index ec1a95c..67260b8 100644 --- a/ld/testsuite/ld-i386/ibt-plt-2d.d +++ b/ld/testsuite/ld-i386/ibt-plt-2d.d @@ -18,31 +18,31 @@ Contents of the .eh_frame section: DW_CFA_nop DW_CFA_nop -0+18 0000001c 0000001c FDE cie=00000000 pc=000001b0..000001ce - DW_CFA_advance_loc: 1 to 000001b1 +0+18 0000001c 0000001c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_advance_loc: 1 to [a-f0-9]+ DW_CFA_def_cfa_offset: 8 DW_CFA_offset: r3 \(ebx\) at cfa-8 - DW_CFA_advance_loc: 14 to 000001bf + DW_CFA_advance_loc: 14 to [a-f0-9]+ DW_CFA_def_cfa_offset: 16 - DW_CFA_advance_loc: 13 to 000001cc + DW_CFA_advance_loc: 13 to [a-f0-9]+ DW_CFA_def_cfa_offset: 8 - DW_CFA_advance_loc: 1 to 000001cd + DW_CFA_advance_loc: 1 to [a-f0-9]+ DW_CFA_restore: r3 \(ebx\) DW_CFA_def_cfa_offset: 4 -0+38 00000010 0000003c FDE cie=00000000 pc=000001ce..000001d2 +0+38 00000010 0000003c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ DW_CFA_nop DW_CFA_nop DW_CFA_nop -0+4c 00000020 00000050 FDE cie=00000000 pc=00000160..00000190 +0+4c 00000020 00000050 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ DW_CFA_def_cfa_offset: 8 - DW_CFA_advance_loc: 6 to 00000166 + DW_CFA_advance_loc: 6 to [a-f0-9]+ DW_CFA_def_cfa_offset: 12 - DW_CFA_advance_loc: 10 to 00000170 + DW_CFA_advance_loc: 10 to [a-f0-9]+ DW_CFA_def_cfa_expression \(DW_OP_breg4 \(esp\): 4; DW_OP_breg8 \(eip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit9; DW_OP_ge; DW_OP_lit2; DW_OP_shl; DW_OP_plus\) -0+70 00000010 00000074 FDE cie=00000000 pc=00000190..000001b0 +0+70 00000010 00000074 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ DW_CFA_nop DW_CFA_nop DW_CFA_nop diff --git a/ld/testsuite/ld-i386/ibt-plt-3d.d b/ld/testsuite/ld-i386/ibt-plt-3d.d index 35742ca..42bd494 100644 --- a/ld/testsuite/ld-i386/ibt-plt-3d.d +++ b/ld/testsuite/ld-i386/ibt-plt-3d.d @@ -18,31 +18,31 @@ Contents of the .eh_frame section: DW_CFA_nop DW_CFA_nop -0+18 0000001c 0000001c FDE cie=00000000 pc=000001b0..000001ce - DW_CFA_advance_loc: 1 to 000001b1 +0+18 0000001c 0000001c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_advance_loc: 1 to [a-f0-9]+ DW_CFA_def_cfa_offset: 8 DW_CFA_offset: r3 \(ebx\) at cfa-8 - DW_CFA_advance_loc: 14 to 000001bf + DW_CFA_advance_loc: 14 to [a-f0-9]+ DW_CFA_def_cfa_offset: 16 - DW_CFA_advance_loc: 13 to 000001cc + DW_CFA_advance_loc: 13 to [a-f0-9]+ DW_CFA_def_cfa_offset: 8 - DW_CFA_advance_loc: 1 to 000001cd + DW_CFA_advance_loc: 1 to [a-f0-9]+ DW_CFA_restore: r3 \(ebx\) DW_CFA_def_cfa_offset: 4 -0+38 00000010 0000003c FDE cie=00000000 pc=000001ce..000001d2 +0+38 00000010 0000003c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ DW_CFA_nop DW_CFA_nop DW_CFA_nop -0+4c 00000020 00000050 FDE cie=00000000 pc=00000160..00000190 +0+4c 00000020 00000050 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ DW_CFA_def_cfa_offset: 8 - DW_CFA_advance_loc: 6 to 00000166 + DW_CFA_advance_loc: 6 to [a-f0-9]+ DW_CFA_def_cfa_offset: 12 - DW_CFA_advance_loc: 10 to 00000170 + DW_CFA_advance_loc: 10 to [a-f0-9]+ DW_CFA_def_cfa_expression \(DW_OP_breg4 \(esp\): 4; DW_OP_breg8 \(eip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit9; DW_OP_ge; DW_OP_lit2; DW_OP_shl; DW_OP_plus\) -0+70 00000010 00000074 FDE cie=00000000 pc=00000190..000001b0 +0+70 00000010 00000074 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ DW_CFA_nop DW_CFA_nop DW_CFA_nop diff --git a/ld/testsuite/ld-i386/pr23372c.d b/ld/testsuite/ld-i386/pr23372c.d index d5bcc4d..58803ab 100644 --- a/ld/testsuite/ld-i386/pr23372c.d +++ b/ld/testsuite/ld-i386/pr23372c.d @@ -7,4 +7,4 @@ Displaying notes found in: .note.gnu.property Owner Data size Description GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 - Properties: x86 ISA used: + Properties: x86 ISA used: <None> |