diff options
Diffstat (limited to 'ld')
39 files changed, 1104 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 84ef78e..62b78b1 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,46 @@ +2017-04-03 H.J. Lu <hongjiu.lu@intel.com> + + * ld/NEWS: Mention support for ELF GNU program properties. + * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Call + ELF setup_gnu_properties. + * testsuite/ld-i386/i386.exp: Run property tests for Linux/i386. + * testsuite/ld-i386/pass.c: New file. + * testsuite/ld-i386/property-1.r: Likewise. + * testsuite/ld-i386/property-2.r: Likewise. + * testsuite/ld-i386/property-3.r: Likewise. + * testsuite/ld-i386/property-4.r: Likewise. + * testsuite/ld-i386/property-5.r: Likewise. + * testsuite/ld-i386/property-6.r: Likewise. + * testsuite/ld-i386/property-6a.c: Likewise. + * testsuite/ld-i386/property-6b.c: Likewise. + * testsuite/ld-i386/property-6c.S: Likewise. + * testsuite/ld-i386/property-7.r: Likewise. + * testsuite/ld-i386/property-no-copy.S: Likewise. + * testsuite/ld-i386/property-stack.S: Likewise. + * testsuite/ld-i386/property-unsorted-1.S: Likewise. + * testsuite/ld-i386/property-unsorted-2.S: Likewise. + * testsuite/ld-i386/property-x86-1.S: Likewise. + * testsuite/ld-i386/property-x86-2.S: Likewise. + * testsuite/ld-x86-64/pass.c: Likewise. + * testsuite/ld-x86-64/property-1.r: Likewise. + * testsuite/ld-x86-64/property-2.r: Likewise. + * testsuite/ld-x86-64/property-3.r: Likewise. + * testsuite/ld-x86-64/property-4.r: Likewise. + * testsuite/ld-x86-64/property-5.r: Likewise. + * testsuite/ld-x86-64/property-6.r: Likewise. + * testsuite/ld-x86-64/property-6a.c: Likewise. + * testsuite/ld-x86-64/property-6b.c: Likewise. + * testsuite/ld-x86-64/property-6c.S: Likewise. + * testsuite/ld-x86-64/property-7.r: Likewise. + * testsuite/ld-x86-64/property-no-copy.S: Likewise. + * testsuite/ld-x86-64/property-stack.S: Likewise. + * testsuite/ld-x86-64/property-unsorted-1.S: Likewise. + * testsuite/ld-x86-64/property-unsorted-2.S: Likewise. + * testsuite/ld-x86-64/property-x86-1.S: Likewise. + * testsuite/ld-x86-64/property-x86-2.S: Likewise. + * testsuite/ld-x86-64/x86-64.exp: Run property tests for + Linux/x86-64. + 2017-03-28 Hans-Peter Nilsson <hp@axis.com> PR ld/16044 @@ -1,5 +1,7 @@ -*- text -*- +* Add support for ELF GNU program properties. + * Add support for the Texas Instruments PRU processor. * When configuring for arc*-*-linux* targets the default linker emulation will diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index d4837d0..007e48d 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1258,6 +1258,8 @@ gld${EMULATION_NAME}_after_open (void) } } + get_elf_backend_data (link_info.output_bfd)->setup_gnu_properties (&link_info); + if (bfd_link_relocatable (&link_info)) { if (link_info.execstack == ! link_info.noexecstack) diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index c489227..844b36f 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -736,6 +736,174 @@ if { [isnative] {{objdump {-dw} pr19319.dd}} \ "pr19319" \ ] \ + [list \ + "Build property 1" \ + "" \ + "" \ + {pass.c property-no-copy.S} \ + {{readelf {-n} property-1.r}} \ + "property-1" \ + ] \ + [list \ + "Build property 1 (.o)" \ + "-r -nostdlib" \ + "" \ + {pass.c property-no-copy.S} \ + {{readelf {-n} property-1.r}} \ + "property-1.o" \ + ] \ + [list \ + "Build property 1 (.so)" \ + "-shared" \ + "-fPIC" \ + {pass.c property-no-copy.S} \ + {{readelf {-n} property-1.r}} \ + "property-1.so" \ + ] \ + [list \ + "Build property 2" \ + "" \ + "" \ + {pass.c property-stack.S} \ + {{readelf {-n} property-2.r}} \ + "property-2" \ + ] \ + [list \ + "Build property 2 (.o)" \ + "-r -nostdlib" \ + "" \ + {pass.c property-stack.S} \ + {{readelf {-n} property-2.r}} \ + "property-2.o" \ + ] \ + [list \ + "Build property 2 (.so)" \ + "-shared" \ + "-fPIC" \ + {pass.c property-stack.S} \ + {{readelf {-n} property-2.r}} \ + "property-2.so" \ + ] \ + [list \ + "Build property 3" \ + "" \ + "" \ + {pass.c property-stack.S property-x86-1.S} \ + {{readelf {-n} property-3.r}} \ + "property-3" \ + ] \ + [list \ + "Build property 3 (.o)" \ + "-r -nostdlib" \ + "" \ + {pass.c property-x86-1.S property-stack.S} \ + {{readelf {-n} property-3.r}} \ + "property-3.o" \ + ] \ + [list \ + "Build property 3 (.so)" \ + "-shared" \ + "-fPIC" \ + {property-x86-1.S pass.c property-stack.S} \ + {{readelf {-n} property-3.r}} \ + "property-3.so" \ + ] \ + [list \ + "Build property 4" \ + "" \ + "" \ + {pass.c property-stack.S property-x86-1.S property-x86-2.S} \ + {{readelf {-n} property-4.r}} \ + "property-4" \ + ] \ + [list \ + "Build property 4 (.o)" \ + "-r -nostdlib" \ + "" \ + {pass.c property-x86-2.S property-x86-1.S property-stack.S} \ + {{readelf {-n} property-4.r}} \ + "property-4.o" \ + ] \ + [list \ + "Build property 4 (.so)" \ + "-shared" \ + "-fPIC" \ + {property-x86-2.S property-x86-1.S pass.c property-stack.S} \ + {{readelf {-n} property-4.r}} \ + "property-4.so" \ + ] \ + [list \ + "Build property 4 (-Wl,-z,stack-size=0)" \ + "-Wl,-z,stack-size=0" \ + "" \ + {pass.c property-stack.S property-x86-1.S property-x86-2.S} \ + {{readelf {-n} property-4.r}} \ + "property-4" \ + ] \ + [list \ + "Build property 5" \ + "-Wl,-z,stack-size=0x900000" \ + "" \ + {pass.c property-stack.S property-x86-1.S property-x86-2.S} \ + {{readelf {-n} property-5.r}} \ + "property-5" \ + ] \ + [list \ + "Build property 5 (.o)" \ + "-r -nostdlib -Wl,-z,stack-size=0x900000" \ + "" \ + {pass.c property-x86-2.S property-x86-1.S property-stack.S} \ + {{readelf {-n} property-5.r}} \ + "property-5.o" \ + ] \ + [list \ + "Build property 5 (.so)" \ + "-shared -Wl,-z,stack-size=0x900000" \ + "-fPIC" \ + {property-x86-2.S property-x86-1.S pass.c property-stack.S} \ + {{readelf {-n} property-5.r}} \ + "property-5.so" \ + ] \ + [list \ + "Build property-6.so" \ + "-shared" \ + "-fPIC" \ + {property-6a.c property-6c.S} \ + {{readelf {-n} property-6.r}} \ + "property-6.so" \ + ] \ + [list \ + "Build property-6.o" \ + "-r -nostdlib" \ + "" \ + {property-6b.c property-stack.S} \ + {{readelf {-n} property-2.r}} \ + "property-6.o" \ + ] \ + [list \ + "Build property-6" \ + "-Wl,--as-needed tmpdir/property-6.o tmpdir/property-6.so" \ + { dummy.s } \ + "" \ + {{readelf {-n} property-2.r}} \ + "property-6" \ + ] \ + [list \ + "Build property 7a (.o)" \ + "-r -nostdlib" \ + "" \ + {property-unsorted-1.S} \ + {{readelf {-n} property-7.r}} \ + "property-7a.o" \ + ] \ + [list \ + "Build property 7b (.o)" \ + "-r -nostdlib" \ + "" \ + {property-unsorted-2.S} \ + {{readelf {-n} property-7.r}} \ + "property-7b.o" \ + ] \ ] run_ld_link_exec_tests [list \ @@ -814,6 +982,111 @@ if { [isnative] "got1" \ "got1.out" \ ] \ + [list \ + "Run property 1" \ + "" \ + "" \ + {pass.c property-no-copy.S} \ + "property-1" "pass.out" \ + ] \ + [list \ + "Run property 1 (PIE)" \ + "-pie" \ + "" \ + {pass.c property-no-copy.S} \ + "property-1-pie" "pass.out" "-fPIE" \ + ] \ + [list \ + "Run property 1 (static)" \ + "-static" \ + "" \ + {pass.c property-no-copy.S} \ + "property-1-static" "pass.out" \ + ] \ + [list \ + "Run property 2" \ + "" \ + "" \ + {pass.c property-stack.S} \ + "property-2" "pass.out" \ + ] \ + [list \ + "Run property 2 (PIE)" \ + "-pie" \ + "" \ + {pass.c property-stack.S} \ + "property-2-pie" "pass.out" "-fPIE" \ + ] \ + [list \ + "Run property 2 (static)" \ + "-static" \ + "" \ + {pass.c property-stack.S} \ + "property-3-static" "pass.out" \ + ] \ + [list \ + "Run property 3" \ + "" \ + "" \ + {pass.c property-stack.S property-x86-1.S} \ + "property-3" "pass.out" \ + ] \ + [list \ + "Run property 3 (PIE)" \ + "-pie" \ + "" \ + {pass.c property-x86-1.S property-stack.S} \ + "property-3-pie" "pass.out" "-fPIE" \ + ] \ + [list \ + "Run property 3 (static)" \ + "-static" \ + "" \ + {property-x86-1.S pass.c property-stack.S} \ + "property-3-static" "pass.out" \ + ] \ + [list \ + "Run property 4" \ + "" \ + "" \ + {pass.c property-stack.S property-x86-1.S property-x86-2.S} \ + "property-4" "pass.out" \ + ] \ + [list \ + "Run property 4 (PIE)" \ + "-pie" \ + "" \ + {pass.c property-x86-2.S property-x86-1.S property-stack.S} \ + "property-4-pie" "pass.out" "-fPIE" \ + ] \ + [list \ + "Run property 4 (static)" \ + "-static" \ + "" \ + {property-x86-2.S property-x86-1.S pass.c property-stack.S} \ + "property-4-static" "pass.out" \ + ] \ + [list \ + "Run property 5" \ + "-Wl,-z,stack-size=0x900000" \ + "" \ + {pass.c property-stack.S property-x86-1.S property-x86-2.S} \ + "property-5" "pass.out" \ + ] \ + [list \ + "Run property 5 (PIE)" \ + "-pie -Wl,-z,stack-size=0x900000" \ + "" \ + {pass.c property-x86-2.S property-x86-1.S property-stack.S} \ + "property-5-pie" "pass.out" "-fPIE" \ + ] \ + [list \ + "Run property 5 (static)" \ + "-static -Wl,-z,stack-size=0x900000" \ + "" \ + {property-x86-2.S property-x86-1.S pass.c property-stack.S} \ + "property-5-static" "pass.out" \ + ] \ ] undefined_weak "" "" diff --git a/ld/testsuite/ld-i386/pass.c b/ld/testsuite/ld-i386/pass.c new file mode 100644 index 0000000..8fb892c --- /dev/null +++ b/ld/testsuite/ld-i386/pass.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int +main () +{ + printf ("PASS\n"); + return 0; +} diff --git a/ld/testsuite/ld-i386/property-1.r b/ld/testsuite/ld-i386/property-1.r new file mode 100644 index 0000000..d8f08c0 --- /dev/null +++ b/ld/testsuite/ld-i386/property-1.r @@ -0,0 +1,7 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: no copy on protected + +#pass diff --git a/ld/testsuite/ld-i386/property-2.r b/ld/testsuite/ld-i386/property-2.r new file mode 100644 index 0000000..5e3d156 --- /dev/null +++ b/ld/testsuite/ld-i386/property-2.r @@ -0,0 +1,7 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 + +#pass diff --git a/ld/testsuite/ld-i386/property-3.r b/ld/testsuite/ld-i386/property-3.r new file mode 100644 index 0000000..0ed91f5 --- /dev/null +++ b/ld/testsuite/ld-i386/property-3.r @@ -0,0 +1,8 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 + x86 ISA used: 586, SSE + x86 ISA needed: i486, 586 +#pass diff --git a/ld/testsuite/ld-i386/property-4.r b/ld/testsuite/ld-i386/property-4.r new file mode 100644 index 0000000..cb2bc15 --- /dev/null +++ b/ld/testsuite/ld-i386/property-4.r @@ -0,0 +1,8 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 + x86 ISA used: i486, 586, SSE + x86 ISA needed: i486, 586, SSE +#pass diff --git a/ld/testsuite/ld-i386/property-5.r b/ld/testsuite/ld-i386/property-5.r new file mode 100644 index 0000000..5529650 --- /dev/null +++ b/ld/testsuite/ld-i386/property-5.r @@ -0,0 +1,8 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x900000 + x86 ISA used: i486, 586, SSE + x86 ISA needed: i486, 586, SSE +#pass diff --git a/ld/testsuite/ld-i386/property-6.r b/ld/testsuite/ld-i386/property-6.r new file mode 100644 index 0000000..97a479f --- /dev/null +++ b/ld/testsuite/ld-i386/property-6.r @@ -0,0 +1,7 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0xa00000 + +#pass diff --git a/ld/testsuite/ld-i386/property-6a.c b/ld/testsuite/ld-i386/property-6a.c new file mode 100644 index 0000000..c7cc10b --- /dev/null +++ b/ld/testsuite/ld-i386/property-6a.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +void +property (void) +{ + printf ("PASS\n"); +} diff --git a/ld/testsuite/ld-i386/property-6b.c b/ld/testsuite/ld-i386/property-6b.c new file mode 100644 index 0000000..5336b0e --- /dev/null +++ b/ld/testsuite/ld-i386/property-6b.c @@ -0,0 +1,8 @@ +extern void property (void); + +int +main () +{ + property (); + return 0; +} diff --git a/ld/testsuite/ld-i386/property-6c.S b/ld/testsuite/ld-i386/property-6c.S new file mode 100644 index 0000000..13f729d --- /dev/null +++ b/ld/testsuite/ld-i386/property-6c.S @@ -0,0 +1,18 @@ + .section ".note.gnu.property", "a" + .p2align 2 + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align 2 + /* GNU_PROPERTY_STACK_SIZE */ + .long 1 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .dc.a 0xa00000 /* Stack size. */ +5: + .p2align 2 +3: diff --git a/ld/testsuite/ld-i386/property-7.r b/ld/testsuite/ld-i386/property-7.r new file mode 100644 index 0000000..ad6af84 --- /dev/null +++ b/ld/testsuite/ld-i386/property-7.r @@ -0,0 +1,6 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 + no copy on protected diff --git a/ld/testsuite/ld-i386/property-no-copy.S b/ld/testsuite/ld-i386/property-no-copy.S new file mode 100644 index 0000000..3116911 --- /dev/null +++ b/ld/testsuite/ld-i386/property-no-copy.S @@ -0,0 +1,15 @@ + .section ".note.gnu.property", "a" + .p2align 2 + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align 2 + /* GNU_PROPERTY_NO_COPY_ON_PROTECTED */ + .long 2 /* pr_type. */ + .long 0 /* pr_datasz. */ + .p2align 2 +3: diff --git a/ld/testsuite/ld-i386/property-stack.S b/ld/testsuite/ld-i386/property-stack.S new file mode 100644 index 0000000..5e9bcce --- /dev/null +++ b/ld/testsuite/ld-i386/property-stack.S @@ -0,0 +1,18 @@ + .section ".note.gnu.property", "a" + .p2align 2 + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align 2 + /* GNU_PROPERTY_STACK_SIZE */ + .long 1 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .dc.a 0x800000 /* Stack size. */ +5: + .p2align 2 +3: diff --git a/ld/testsuite/ld-i386/property-unsorted-1.S b/ld/testsuite/ld-i386/property-unsorted-1.S new file mode 100644 index 0000000..1cbb272 --- /dev/null +++ b/ld/testsuite/ld-i386/property-unsorted-1.S @@ -0,0 +1,34 @@ + .section ".note.gnu.property", "a" + .p2align 2 + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align 2 + /* GNU_PROPERTY_NO_COPY_ON_PROTECTED */ + .long 2 /* pr_type. */ + .long 0 /* pr_datasz. */ + .p2align 2 +3: + + .section ".note.gnu.property", "a" + .p2align 2 + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align 2 + /* GNU_PROPERTY_STACK_SIZE */ + .long 1 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .dc.a 0x800000 /* Stack size. */ +5: + .p2align 2 +3: diff --git a/ld/testsuite/ld-i386/property-unsorted-2.S b/ld/testsuite/ld-i386/property-unsorted-2.S new file mode 100644 index 0000000..0289399 --- /dev/null +++ b/ld/testsuite/ld-i386/property-unsorted-2.S @@ -0,0 +1,22 @@ + .section ".note.gnu.property", "a" + .p2align 2 + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align 2 + /* GNU_PROPERTY_NO_COPY_ON_PROTECTED */ + .long 2 /* pr_type. */ + .long 0 /* pr_datasz. */ + .p2align 2 + /* GNU_PROPERTY_STACK_SIZE */ + .long 1 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .dc.a 0x800000 /* Stack size. */ +5: + .p2align 2 +3: diff --git a/ld/testsuite/ld-i386/property-x86-1.S b/ld/testsuite/ld-i386/property-x86-1.S new file mode 100644 index 0000000..953ca87 --- /dev/null +++ b/ld/testsuite/ld-i386/property-x86-1.S @@ -0,0 +1,32 @@ + .section ".note.gnu.property", "a" + .p2align 2 + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align 2 + /* GNU_PROPERTY_STACK_SIZE */ + .long 1 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .dc.a 0x600000 /* Stack size. */ +5: + .p2align 2 + /* GNU_PROPERTY_X86_ISA_1_USED */ + .long 0xc0000000 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0xa +5: + .p2align 2 + /* GNU_PROPERTY_X86_ISA_1_NEEDED */ + .long 0xc0000001 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0x3 +5: + .p2align 2 +3: diff --git a/ld/testsuite/ld-i386/property-x86-2.S b/ld/testsuite/ld-i386/property-x86-2.S new file mode 100644 index 0000000..f11e1fe --- /dev/null +++ b/ld/testsuite/ld-i386/property-x86-2.S @@ -0,0 +1,25 @@ + .section ".note.gnu.property", "a" + .p2align 2 + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align 2 + /* GNU_PROPERTY_X86_ISA_1_USED */ + .long 0xc0000000 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0x3 +5: + .p2align 2 + /* GNU_PROPERTY_X86_ISA_1_NEEDED */ + .long 0xc0000001 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0xa +5: + .p2align 2 +3: diff --git a/ld/testsuite/ld-x86-64/pass.c b/ld/testsuite/ld-x86-64/pass.c new file mode 100644 index 0000000..8fb892c --- /dev/null +++ b/ld/testsuite/ld-x86-64/pass.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int +main () +{ + printf ("PASS\n"); + return 0; +} diff --git a/ld/testsuite/ld-x86-64/property-1.r b/ld/testsuite/ld-x86-64/property-1.r new file mode 100644 index 0000000..d8f08c0 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-1.r @@ -0,0 +1,7 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: no copy on protected + +#pass diff --git a/ld/testsuite/ld-x86-64/property-2.r b/ld/testsuite/ld-x86-64/property-2.r new file mode 100644 index 0000000..5e3d156 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-2.r @@ -0,0 +1,7 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 + +#pass diff --git a/ld/testsuite/ld-x86-64/property-3.r b/ld/testsuite/ld-x86-64/property-3.r new file mode 100644 index 0000000..0ed91f5 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-3.r @@ -0,0 +1,8 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 + x86 ISA used: 586, SSE + x86 ISA needed: i486, 586 +#pass diff --git a/ld/testsuite/ld-x86-64/property-4.r b/ld/testsuite/ld-x86-64/property-4.r new file mode 100644 index 0000000..cb2bc15 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-4.r @@ -0,0 +1,8 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 + x86 ISA used: i486, 586, SSE + x86 ISA needed: i486, 586, SSE +#pass diff --git a/ld/testsuite/ld-x86-64/property-5.r b/ld/testsuite/ld-x86-64/property-5.r new file mode 100644 index 0000000..5529650 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-5.r @@ -0,0 +1,8 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x900000 + x86 ISA used: i486, 586, SSE + x86 ISA needed: i486, 586, SSE +#pass diff --git a/ld/testsuite/ld-x86-64/property-6.r b/ld/testsuite/ld-x86-64/property-6.r new file mode 100644 index 0000000..97a479f --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-6.r @@ -0,0 +1,7 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0xa00000 + +#pass diff --git a/ld/testsuite/ld-x86-64/property-6a.c b/ld/testsuite/ld-x86-64/property-6a.c new file mode 100644 index 0000000..c7cc10b --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-6a.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +void +property (void) +{ + printf ("PASS\n"); +} diff --git a/ld/testsuite/ld-x86-64/property-6b.c b/ld/testsuite/ld-x86-64/property-6b.c new file mode 100644 index 0000000..5336b0e --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-6b.c @@ -0,0 +1,8 @@ +extern void property (void); + +int +main () +{ + property (); + return 0; +} diff --git a/ld/testsuite/ld-x86-64/property-6c.S b/ld/testsuite/ld-x86-64/property-6c.S new file mode 100644 index 0000000..41246d3 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-6c.S @@ -0,0 +1,23 @@ +#ifdef __LP64__ +# define ALIGN 3 +#else +# define ALIGN 2 +#endif + .section ".note.gnu.property", "a" + .p2align ALIGN + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align ALIGN + /* GNU_PROPERTY_STACK_SIZE */ + .long 1 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .dc.a 0xa00000 /* Stack size. */ +5: + .p2align ALIGN +3: diff --git a/ld/testsuite/ld-x86-64/property-7.r b/ld/testsuite/ld-x86-64/property-7.r new file mode 100644 index 0000000..ad6af84 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-7.r @@ -0,0 +1,6 @@ +#... +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 + no copy on protected diff --git a/ld/testsuite/ld-x86-64/property-no-copy.S b/ld/testsuite/ld-x86-64/property-no-copy.S new file mode 100644 index 0000000..88cc252 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-no-copy.S @@ -0,0 +1,20 @@ +#ifdef __LP64__ +# define ALIGN 3 +#else +# define ALIGN 2 +#endif + .section ".note.gnu.property", "a" + .p2align ALIGN + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align ALIGN + /* GNU_PROPERTY_NO_COPY_ON_PROTECTED */ + .long 2 /* pr_type. */ + .long 0 /* pr_datasz. */ + .p2align ALIGN +3: diff --git a/ld/testsuite/ld-x86-64/property-stack.S b/ld/testsuite/ld-x86-64/property-stack.S new file mode 100644 index 0000000..7f45654 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-stack.S @@ -0,0 +1,23 @@ +#ifdef __LP64__ +# define ALIGN 3 +#else +# define ALIGN 2 +#endif + .section ".note.gnu.property", "a" + .p2align ALIGN + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align ALIGN + /* GNU_PROPERTY_STACK_SIZE */ + .long 1 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .dc.a 0x800000 /* Stack size. */ +5: + .p2align ALIGN +3: diff --git a/ld/testsuite/ld-x86-64/property-unsorted-1.S b/ld/testsuite/ld-x86-64/property-unsorted-1.S new file mode 100644 index 0000000..de96e7a --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-unsorted-1.S @@ -0,0 +1,39 @@ +#ifdef __LP64__ +# define ALIGN 3 +#else +# define ALIGN 2 +#endif + .section ".note.gnu.property", "a" + .p2align ALIGN + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align ALIGN + /* GNU_PROPERTY_NO_COPY_ON_PROTECTED */ + .long 2 /* pr_type. */ + .long 0 /* pr_datasz. */ + .p2align ALIGN +3: + + .section ".note.gnu.property", "a" + .p2align ALIGN + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align ALIGN + /* GNU_PROPERTY_STACK_SIZE */ + .long 1 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .dc.a 0x800000 /* Stack size. */ +5: + .p2align ALIGN +3: diff --git a/ld/testsuite/ld-x86-64/property-unsorted-2.S b/ld/testsuite/ld-x86-64/property-unsorted-2.S new file mode 100644 index 0000000..65d7fad --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-unsorted-2.S @@ -0,0 +1,27 @@ +#ifdef __LP64__ +# define ALIGN 3 +#else +# define ALIGN 2 +#endif + .section ".note.gnu.property", "a" + .p2align ALIGN + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align ALIGN + /* GNU_PROPERTY_NO_COPY_ON_PROTECTED */ + .long 2 /* pr_type. */ + .long 0 /* pr_datasz. */ + .p2align ALIGN + /* GNU_PROPERTY_STACK_SIZE */ + .long 1 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .dc.a 0x800000 /* Stack size. */ +5: + .p2align ALIGN +3: diff --git a/ld/testsuite/ld-x86-64/property-x86-1.S b/ld/testsuite/ld-x86-64/property-x86-1.S new file mode 100644 index 0000000..33f2ccd --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-1.S @@ -0,0 +1,37 @@ +#ifdef __LP64__ +# define ALIGN 3 +#else +# define ALIGN 2 +#endif + .section ".note.gnu.property", "a" + .p2align ALIGN + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align ALIGN + /* GNU_PROPERTY_STACK_SIZE */ + .long 1 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .dc.a 0x600000 /* Stack size. */ +5: + .p2align ALIGN + /* GNU_PROPERTY_X86_ISA_1_USED */ + .long 0xc0000000 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0xa +5: + .p2align ALIGN + /* GNU_PROPERTY_X86_ISA_1_NEEDED */ + .long 0xc0000001 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0x3 +5: + .p2align ALIGN +3: diff --git a/ld/testsuite/ld-x86-64/property-x86-2.S b/ld/testsuite/ld-x86-64/property-x86-2.S new file mode 100644 index 0000000..132e521 --- /dev/null +++ b/ld/testsuite/ld-x86-64/property-x86-2.S @@ -0,0 +1,30 @@ +#ifdef __LP64__ +# define ALIGN 3 +#else +# define ALIGN 2 +#endif + .section ".note.gnu.property", "a" + .p2align ALIGN + .long 1f - 0f /* name length. */ + .long 3f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0 */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align ALIGN + /* GNU_PROPERTY_X86_ISA_1_USED */ + .long 0xc0000000 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0x3 +5: + .p2align ALIGN + /* GNU_PROPERTY_X86_ISA_1_NEEDED */ + .long 0xc0000001 /* pr_type. */ + .long 5f - 4f /* pr_datasz. */ +4: + .long 0xa +5: + .p2align ALIGN +3: diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 8e4e422..e7a7f80 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -828,6 +828,174 @@ if { [isnative] && [which $CC] != 0 } { {{objdump {-dw} pr19319.dd}} \ "pr19319" \ ] \ + [list \ + "Build property 1" \ + "" \ + "" \ + {pass.c property-no-copy.S} \ + {{readelf {-n} property-1.r}} \ + "property-1" \ + ] \ + [list \ + "Build property 1 (.o)" \ + "-r -nostdlib" \ + "" \ + {pass.c property-no-copy.S} \ + {{readelf {-n} property-1.r}} \ + "property-1.o" \ + ] \ + [list \ + "Build property 1 (.so)" \ + "-shared" \ + "-fPIC" \ + {pass.c property-no-copy.S} \ + {{readelf {-n} property-1.r}} \ + "property-1.so" \ + ] \ + [list \ + "Build property 2" \ + "" \ + "" \ + {pass.c property-stack.S} \ + {{readelf {-n} property-2.r}} \ + "property-2" \ + ] \ + [list \ + "Build property 2 (.o)" \ + "-r -nostdlib" \ + "" \ + {pass.c property-stack.S} \ + {{readelf {-n} property-2.r}} \ + "property-2.o" \ + ] \ + [list \ + "Build property 2 (.so)" \ + "-shared" \ + "-fPIC" \ + {pass.c property-stack.S} \ + {{readelf {-n} property-2.r}} \ + "property-2.so" \ + ] \ + [list \ + "Build property 3" \ + "" \ + "" \ + {pass.c property-stack.S property-x86-1.S} \ + {{readelf {-n} property-3.r}} \ + "property-3" \ + ] \ + [list \ + "Build property 3 (.o)" \ + "-r -nostdlib" \ + "" \ + {pass.c property-x86-1.S property-stack.S} \ + {{readelf {-n} property-3.r}} \ + "property-3.o" \ + ] \ + [list \ + "Build property 3 (.so)" \ + "-shared" \ + "-fPIC" \ + {property-x86-1.S pass.c property-stack.S} \ + {{readelf {-n} property-3.r}} \ + "property-3.so" \ + ] \ + [list \ + "Build property 4" \ + "" \ + "" \ + {pass.c property-stack.S property-x86-1.S property-x86-2.S} \ + {{readelf {-n} property-4.r}} \ + "property-4" \ + ] \ + [list \ + "Build property 4 (.o)" \ + "-r -nostdlib" \ + "" \ + {pass.c property-x86-2.S property-x86-1.S property-stack.S} \ + {{readelf {-n} property-4.r}} \ + "property-4.o" \ + ] \ + [list \ + "Build property 4 (.so)" \ + "-shared" \ + "-fPIC" \ + {property-x86-2.S property-x86-1.S pass.c property-stack.S} \ + {{readelf {-n} property-4.r}} \ + "property-4.so" \ + ] \ + [list \ + "Build property 4 (-Wl,-z,stack-size=0)" \ + "-Wl,-z,stack-size=0" \ + "" \ + {pass.c property-stack.S property-x86-1.S property-x86-2.S} \ + {{readelf {-n} property-4.r}} \ + "property-4" \ + ] \ + [list \ + "Build property 5" \ + "-Wl,-z,stack-size=0x900000" \ + "" \ + {pass.c property-stack.S property-x86-1.S property-x86-2.S} \ + {{readelf {-n} property-5.r}} \ + "property-5" \ + ] \ + [list \ + "Build property 5 (.o)" \ + "-r -nostdlib -Wl,-z,stack-size=0x900000" \ + "" \ + {pass.c property-x86-2.S property-x86-1.S property-stack.S} \ + {{readelf {-n} property-5.r}} \ + "property-5.o" \ + ] \ + [list \ + "Build property 5 (.so)" \ + "-shared -Wl,-z,stack-size=0x900000" \ + "-fPIC" \ + {property-x86-2.S property-x86-1.S pass.c property-stack.S} \ + {{readelf {-n} property-5.r}} \ + "property-5.so" \ + ] \ + [list \ + "Build property-6.so" \ + "-shared" \ + "-fPIC" \ + {property-6a.c property-6c.S} \ + {{readelf {-n} property-6.r}} \ + "property-6.so" \ + ] \ + [list \ + "Build property-6.o" \ + "-r -nostdlib" \ + "" \ + {property-6b.c property-stack.S} \ + {{readelf {-n} property-2.r}} \ + "property-6.o" \ + ] \ + [list \ + "Build property-6" \ + "-Wl,--as-needed tmpdir/property-6.o tmpdir/property-6.so" \ + { dummy.s } \ + "" \ + {{readelf {-n} property-2.r}} \ + "property-6" \ + ] \ + [list \ + "Build property 7a (.o)" \ + "-r -nostdlib" \ + "" \ + {property-unsorted-1.S} \ + {{readelf {-n} property-7.r}} \ + "property-7a.o" \ + ] \ + [list \ + "Build property 7b (.o)" \ + "-r -nostdlib" \ + "" \ + {property-unsorted-2.S} \ + {{readelf {-n} property-7.r}} \ + "property-7b.o" \ + ] \ ] run_ld_link_exec_tests [list \ @@ -898,6 +1066,111 @@ if { [isnative] && [which $CC] != 0 } { "gotpcrel1" \ "gotpcrel1.out" \ ] \ + [list \ + "Run property 1" \ + "" \ + "" \ + {pass.c property-no-copy.S} \ + "property-1" "pass.out" \ + ] \ + [list \ + "Run property 1 (PIE)" \ + "-pie" \ + "" \ + {pass.c property-no-copy.S} \ + "property-1-pie" "pass.out" "-fPIE" \ + ] \ + [list \ + "Run property 1 (static)" \ + "-static" \ + "" \ + {pass.c property-no-copy.S} \ + "property-1-static" "pass.out" \ + ] \ + [list \ + "Run property 2" \ + "" \ + "" \ + {pass.c property-stack.S} \ + "property-2" "pass.out" \ + ] \ + [list \ + "Run property 2 (PIE)" \ + "-pie" \ + "" \ + {pass.c property-stack.S} \ + "property-2-pie" "pass.out" "-fPIE" \ + ] \ + [list \ + "Run property 2 (static)" \ + "-static" \ + "" \ + {pass.c property-stack.S} \ + "property-3-static" "pass.out" \ + ] \ + [list \ + "Run property 3" \ + "" \ + "" \ + {pass.c property-stack.S property-x86-1.S} \ + "property-3" "pass.out" \ + ] \ + [list \ + "Run property 3 (PIE)" \ + "-pie" \ + "" \ + {pass.c property-x86-1.S property-stack.S} \ + "property-3-pie" "pass.out" "-fPIE" \ + ] \ + [list \ + "Run property 3 (static)" \ + "-static" \ + "" \ + {property-x86-1.S pass.c property-stack.S} \ + "property-3-static" "pass.out" \ + ] \ + [list \ + "Run property 4" \ + "" \ + "" \ + {pass.c property-stack.S property-x86-1.S property-x86-2.S} \ + "property-4" "pass.out" \ + ] \ + [list \ + "Run property 4 (PIE)" \ + "-pie" \ + "" \ + {pass.c property-x86-2.S property-x86-1.S property-stack.S} \ + "property-4-pie" "pass.out" "-fPIE" \ + ] \ + [list \ + "Run property 4 (static)" \ + "-static" \ + "" \ + {property-x86-2.S property-x86-1.S pass.c property-stack.S} \ + "property-4-static" "pass.out" \ + ] \ + [list \ + "Run property 5" \ + "-Wl,-z,stack-size=0x900000" \ + "" \ + {pass.c property-stack.S property-x86-1.S property-x86-2.S} \ + "property-5" "pass.out" \ + ] \ + [list \ + "Run property 5 (PIE)" \ + "-pie -Wl,-z,stack-size=0x900000" \ + "" \ + {pass.c property-x86-2.S property-x86-1.S property-stack.S} \ + "property-5-pie" "pass.out" "-fPIE" \ + ] \ + [list \ + "Run property 5 (static)" \ + "-static -Wl,-z,stack-size=0x900000" \ + "" \ + {property-x86-2.S property-x86-1.S pass.c property-stack.S} \ + "property-5-static" "pass.out" \ + ] \ ] # Run-time tests which require working ifunc attribute support. |