diff options
Diffstat (limited to 'ld')
25 files changed, 94 insertions, 18 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index e390c9e..870fe1a 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2012-10-23 Nathan Sidwell <nathan@codesourcery.com> + + * ld.texinfo (stack-size): New option. + * emultempl/elf32.em: Add stack-size option. + 2012-10-22 Jan Beich <jbeich@tormail.org> Alan Modra <amodra@gmail.com> diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index de51050..f6d4c44 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -2276,6 +2276,17 @@ fragment <<EOF einfo (_("%P%F: invalid common page size \`%s'\n"), optarg + 17); } + else if (CONST_STRNEQ (optarg, "stack-size=")) + { + char *end; + link_info.stacksize = strtoul (optarg + 11, &end, 0); + if (*end || link_info.stacksize < 0) + einfo (_("%P%F: invalid stack size \`%s'\n"), optarg + 11); + if (!link_info.stacksize) + /* Use -1 for explicit no-stack, because zero means + 'default'. */ + link_info.stacksize = -1; + } else if (strcmp (optarg, "execstack") == 0) { link_info.execstack = TRUE; diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 9bd9c7c..4a8118f 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -1093,6 +1093,11 @@ Set the emulation maximum page size to @var{value}. @item common-page-size=@var{value} Set the emulation common page size to @var{value}. +@item stack-size=@var{value} +Specify a stack size for in an ELF @code{PT_GNU_STACK} segment. +Specifying zero will override any default non-zero sized +@code{PT_GNU_STACK} segment creation. + @end table Other keywords are ignored for Solaris compatibility. diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index a27d274..d0a777c 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,27 @@ +2012-10-23 Nathan Sidwell <nathan@codesourcery.com> + + * ld-elf/binutils.exp: Add -z stack-size=0. + * ld-elf/elf.exp: Add stack-exec and stack-size tests. + * ld-elf/orphan-region.d: Add stack-size option. Remove xfail. + * ld-elf/stack-exec.rd: New. + * ld-elf/stack-size.rd: New. + * ld-elf/stack.s: New. + * ld-scripts/empty-aligned.d: Add stack-size option. + * ld-sh/fdpic-stack-set.d: New. + * ld-tic6x/shlib-1.rd: Remove __stacksize symbol. + * ld-tic6x/shlib-1b.rd: Likewise. + * ld-tic6x/shlib-1r.rd: Likewise. + * ld-tic6x/shlib-1rb.rd: Likewise. + * ld-tic6x/shlib-app-1.rd: Likewise. + * ld-tic6x/shlib-app-1b.rd: Likewise. + * ld-tic6x/shlib-app-1r.rd: Likewise. + * ld-tic6x/shlib-app-1rb.rd: Likewise. + * ld-tic6x/shlib-noindex.rd: Likewise. + * ld-tic6x/static-app-1.rd: Likewise. + * ld-tic6x/static-app-1b.rd: Likewise. + * ld-tic6x/static-app-1r.rd: Likewise. + * ld-tic6x/static-app-1rb.rd: Likewise. + 2012-10-16 Sofiane Naci <sofiane.naci@arm.com> * ld-aarch64/tlsle-symbol-offset.s: New file. diff --git a/ld/testsuite/ld-elf/binutils.exp b/ld/testsuite/ld-elf/binutils.exp index 249fa2a..0101512 100644 --- a/ld/testsuite/ld-elf/binutils.exp +++ b/ld/testsuite/ld-elf/binutils.exp @@ -60,7 +60,7 @@ proc binutils_test { prog_name ld_options test {test_name ""}} { return } - if { ![ld_simple_link $ld tmpdir/$test "$ld_options tmpdir/$test.o"] } { + if { ![ld_simple_link $ld tmpdir/$test "$ld_options -z stack-size=0 tmpdir/$test.o"] } { if { [string match "*not supported*" $link_output] || [string match "*unrecognized option*" $link_output] || [string match "*-z relro ignored*" $link_output] } { diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp index a97e3df..a33e3b6 100644 --- a/ld/testsuite/ld-elf/elf.exp +++ b/ld/testsuite/ld-elf/elf.exp @@ -126,6 +126,15 @@ if { [check_gc_sections_available] && ![istarget "v850-*-*"] } { } } +if { [istarget *-*-*linux*] } { + run_ld_link_tests { + {"stack exec" "-z execstack" "" {stack.s} + {{readelf {-Wl} stack-exec.rd}} "stack-exec.exe"} + {"stack size" "-z stack-size=0x123400" "" {stack.s} + {{readelf {-Wl} stack-size.rd}} "stack-size.exe"} + } +} + set LDFLAGS $old_ldflags # The following tests require running the executable generated by ld. diff --git a/ld/testsuite/ld-elf/orphan-region.d b/ld/testsuite/ld-elf/orphan-region.d index 9d6c90c..d961a07 100644 --- a/ld/testsuite/ld-elf/orphan-region.d +++ b/ld/testsuite/ld-elf/orphan-region.d @@ -1,11 +1,11 @@ #source: orphan-region.s -#ld: -T orphan-region.ld -N +#ld: -T orphan-region.ld -N -z stack-size=0 #readelf: -S -l --wide #xfail: arc-*-* d30v-*-* dlx-*-* fr30-*-* frv-*-elf i860-*-* i960-*-* #xfail: iq*-*-* mn10200-*-* moxie-*-* msp*-*-* mt-*-* or32-*-* pj*-*-* -#xfail: spu-*-* hppa*64*-*-* frv-*-* +#xfail: spu-*-* hppa*64*-*-* # if not using elf32.em, you don't get fancy orphan handling -# spu twiddles LOAD range, hppa64 adds PHDR, frv-linux adds GNU_STACK +# spu twiddles LOAD range, hppa64 adds PHDR #... \[[ 0-9]+\] \.text[ \t]+PROGBITS[ \t]+0*40000000[ \t]+.* diff --git a/ld/testsuite/ld-elf/stack-exec.rd b/ld/testsuite/ld-elf/stack-exec.rd new file mode 100644 index 0000000..7f68a6c --- /dev/null +++ b/ld/testsuite/ld-elf/stack-exec.rd @@ -0,0 +1,3 @@ +#... + GNU_STACK 0x0+00000 0x0+000000 0x0+000000 0x0+000 0x.+0000 RWE 0x[0-9a-f]+ +#pass diff --git a/ld/testsuite/ld-elf/stack-size.rd b/ld/testsuite/ld-elf/stack-size.rd new file mode 100644 index 0000000..413db3a9 --- /dev/null +++ b/ld/testsuite/ld-elf/stack-size.rd @@ -0,0 +1,3 @@ +#... + GNU_STACK 0x0+00000 0x0+000000 0x0+000000 0x0+000 0x123400 RW. 0x[0-9a-f]+ +#pass diff --git a/ld/testsuite/ld-elf/stack.s b/ld/testsuite/ld-elf/stack.s new file mode 100644 index 0000000..b92617b --- /dev/null +++ b/ld/testsuite/ld-elf/stack.s @@ -0,0 +1,10 @@ + .text + .globl start + .globl _start +start: +_start: + nop + nop + nop + nop + diff --git a/ld/testsuite/ld-scripts/empty-aligned.d b/ld/testsuite/ld-scripts/empty-aligned.d index 283ef64..4a0c87c 100644 --- a/ld/testsuite/ld-scripts/empty-aligned.d +++ b/ld/testsuite/ld-scripts/empty-aligned.d @@ -1,5 +1,5 @@ #source: empty-aligned.s -#ld: -T empty-aligned.t +#ld: -T empty-aligned.t -z stack-size=0 #readelf: -l --wide #xfail: "hppa64-*-*" #notarget: frv-*-*linux* diff --git a/ld/testsuite/ld-sh/fdpic-stack-set.d b/ld/testsuite/ld-sh/fdpic-stack-set.d new file mode 100644 index 0000000..3bdb783 --- /dev/null +++ b/ld/testsuite/ld-sh/fdpic-stack-set.d @@ -0,0 +1,19 @@ +#source: fdpic-stack.s +#as: --isa=sh2a -big --fdpic +#ld: -EB -mshelf_fd -z stack-size=0x40000 +#readelf: -l +#target: sh*-*-uclinux* + +Elf file type is EXEC \(Executable file\) +Entry point 0x400074 +There are 2 program headers, starting at offset 52 + +Program Headers: +[ \t]+Type[ \t]+Offset[ \t]+VirtAddr[ \t]+PhysAddr[ \t]+FileSiz MemSiz[ \t]+Flg Align +[ \t]+LOAD[ \t]+0x000000 0x00400000 0x00400000 0x00076 0x00076 R E 0x10000 +[ \t]+GNU_STACK[ \t]+0x000000 0x00000000 0x00000000 0x00000 0x40000 RWE 0x8 + + Section to Segment mapping: +[ \t]+Segment Sections\.\.\. +[ \t]+00[ \t]+\.text +[ \t]+01[ \t]+ diff --git a/ld/testsuite/ld-tic6x/shlib-1.rd b/ld/testsuite/ld-tic6x/shlib-1.rd index d3bf087..029bda1 100644 --- a/ld/testsuite/ld-tic6x/shlib-1.rd +++ b/ld/testsuite/ld-tic6x/shlib-1.rd @@ -117,7 +117,6 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* 1000010c 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ .* 10000100 0 NOTYPE LOCAL DEFAULT 10 __c6xabi_DSBT_BASE .* 00000000 0 NOTYPE WEAK DEFAULT UND b -.* 00020000 0 OBJECT GLOBAL DEFAULT ABS __stacksize .* 00000000 0 NOTYPE WEAK DEFAULT UND g1 .* 1000012c 4 OBJECT GLOBAL DEFAULT 11 g2 .* 10000088 52 FUNC GLOBAL DEFAULT 9 sub0 diff --git a/ld/testsuite/ld-tic6x/shlib-1b.rd b/ld/testsuite/ld-tic6x/shlib-1b.rd index d3bf087..029bda1 100644 --- a/ld/testsuite/ld-tic6x/shlib-1b.rd +++ b/ld/testsuite/ld-tic6x/shlib-1b.rd @@ -117,7 +117,6 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* 1000010c 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ .* 10000100 0 NOTYPE LOCAL DEFAULT 10 __c6xabi_DSBT_BASE .* 00000000 0 NOTYPE WEAK DEFAULT UND b -.* 00020000 0 OBJECT GLOBAL DEFAULT ABS __stacksize .* 00000000 0 NOTYPE WEAK DEFAULT UND g1 .* 1000012c 4 OBJECT GLOBAL DEFAULT 11 g2 .* 10000088 52 FUNC GLOBAL DEFAULT 9 sub0 diff --git a/ld/testsuite/ld-tic6x/shlib-1r.rd b/ld/testsuite/ld-tic6x/shlib-1r.rd index d3bf087..029bda1 100644 --- a/ld/testsuite/ld-tic6x/shlib-1r.rd +++ b/ld/testsuite/ld-tic6x/shlib-1r.rd @@ -117,7 +117,6 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* 1000010c 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ .* 10000100 0 NOTYPE LOCAL DEFAULT 10 __c6xabi_DSBT_BASE .* 00000000 0 NOTYPE WEAK DEFAULT UND b -.* 00020000 0 OBJECT GLOBAL DEFAULT ABS __stacksize .* 00000000 0 NOTYPE WEAK DEFAULT UND g1 .* 1000012c 4 OBJECT GLOBAL DEFAULT 11 g2 .* 10000088 52 FUNC GLOBAL DEFAULT 9 sub0 diff --git a/ld/testsuite/ld-tic6x/shlib-1rb.rd b/ld/testsuite/ld-tic6x/shlib-1rb.rd index d3bf087..029bda1 100644 --- a/ld/testsuite/ld-tic6x/shlib-1rb.rd +++ b/ld/testsuite/ld-tic6x/shlib-1rb.rd @@ -117,7 +117,6 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* 1000010c 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ .* 10000100 0 NOTYPE LOCAL DEFAULT 10 __c6xabi_DSBT_BASE .* 00000000 0 NOTYPE WEAK DEFAULT UND b -.* 00020000 0 OBJECT GLOBAL DEFAULT ABS __stacksize .* 00000000 0 NOTYPE WEAK DEFAULT UND g1 .* 1000012c 4 OBJECT GLOBAL DEFAULT 11 g2 .* 10000088 52 FUNC GLOBAL DEFAULT 9 sub0 diff --git a/ld/testsuite/ld-tic6x/shlib-app-1.rd b/ld/testsuite/ld-tic6x/shlib-app-1.rd index 6461371..9c691c9 100644 --- a/ld/testsuite/ld-tic6x/shlib-app-1.rd +++ b/ld/testsuite/ld-tic6x/shlib-app-1.rd @@ -122,7 +122,6 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* 100000ac 0 OBJECT LOCAL DEFAULT 11 _GLOBAL_OFFSET_TABLE_ .* 100000a0 0 NOTYPE LOCAL DEFAULT 11 __c6xabi_DSBT_BASE .* 100000c0 4 OBJECT GLOBAL DEFAULT 12 b -.* 00020000 0 OBJECT GLOBAL DEFAULT ABS __stacksize .* 00000000 0 NOTYPE WEAK DEFAULT UND g1 .* 00000000 0 OBJECT WEAK DEFAULT UND g2 .* 00000000 0 FUNC GLOBAL DEFAULT UND sub0 diff --git a/ld/testsuite/ld-tic6x/shlib-app-1b.rd b/ld/testsuite/ld-tic6x/shlib-app-1b.rd index f4e8188..a541a5c 100644 --- a/ld/testsuite/ld-tic6x/shlib-app-1b.rd +++ b/ld/testsuite/ld-tic6x/shlib-app-1b.rd @@ -122,7 +122,6 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* 100000ac 0 OBJECT LOCAL DEFAULT 11 _GLOBAL_OFFSET_TABLE_ .* 100000a0 0 NOTYPE LOCAL DEFAULT 11 __c6xabi_DSBT_BASE .* 100000c0 4 OBJECT GLOBAL DEFAULT 12 b -.* 00020000 0 OBJECT GLOBAL DEFAULT ABS __stacksize .* 00000000 0 NOTYPE WEAK DEFAULT UND g1 .* 00000000 0 OBJECT WEAK DEFAULT UND g2 .* 00000000 0 FUNC GLOBAL DEFAULT UND sub0 diff --git a/ld/testsuite/ld-tic6x/shlib-app-1r.rd b/ld/testsuite/ld-tic6x/shlib-app-1r.rd index b00447c..5c1b675 100644 --- a/ld/testsuite/ld-tic6x/shlib-app-1r.rd +++ b/ld/testsuite/ld-tic6x/shlib-app-1r.rd @@ -112,6 +112,5 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* 100000ac 0 OBJECT LOCAL DEFAULT 10 _GLOBAL_OFFSET_TABLE_ .* 100000a0 0 NOTYPE LOCAL DEFAULT 10 __c6xabi_DSBT_BASE .* 100000c0 4 OBJECT GLOBAL DEFAULT 11 b -.* 00020000 0 OBJECT GLOBAL DEFAULT ABS __stacksize .* 00000000 0 FUNC GLOBAL DEFAULT UND sub0 .* 100000c4 4 OBJECT GLOBAL DEFAULT 12 a diff --git a/ld/testsuite/ld-tic6x/shlib-app-1rb.rd b/ld/testsuite/ld-tic6x/shlib-app-1rb.rd index 7c2c110..d121832 100644 --- a/ld/testsuite/ld-tic6x/shlib-app-1rb.rd +++ b/ld/testsuite/ld-tic6x/shlib-app-1rb.rd @@ -112,6 +112,5 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* 100000ac 0 OBJECT LOCAL DEFAULT 10 _GLOBAL_OFFSET_TABLE_ .* 100000a0 0 NOTYPE LOCAL DEFAULT 10 __c6xabi_DSBT_BASE .* 100000c0 4 OBJECT GLOBAL DEFAULT 11 b -.* 00020000 0 OBJECT GLOBAL DEFAULT ABS __stacksize .* 00000000 0 FUNC GLOBAL DEFAULT UND sub0 .* 100000c4 4 OBJECT GLOBAL DEFAULT 12 a diff --git a/ld/testsuite/ld-tic6x/shlib-noindex.rd b/ld/testsuite/ld-tic6x/shlib-noindex.rd index 3d50e68..e030b17 100644 --- a/ld/testsuite/ld-tic6x/shlib-noindex.rd +++ b/ld/testsuite/ld-tic6x/shlib-noindex.rd @@ -124,7 +124,6 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* 1000010c 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ .* 10000100 0 NOTYPE LOCAL DEFAULT 11 __c6xabi_DSBT_BASE .* 00000000 0 NOTYPE WEAK DEFAULT UND b -.* 00020000 0 OBJECT GLOBAL DEFAULT ABS __stacksize .* 00000000 0 NOTYPE WEAK DEFAULT UND g1 .* 1000012c 4 OBJECT GLOBAL DEFAULT 12 g2 .* 10000088 52 FUNC GLOBAL DEFAULT 10 sub0 diff --git a/ld/testsuite/ld-tic6x/static-app-1.rd b/ld/testsuite/ld-tic6x/static-app-1.rd index ae5bc8d..c56d637 100644 --- a/ld/testsuite/ld-tic6x/static-app-1.rd +++ b/ld/testsuite/ld-tic6x/static-app-1.rd @@ -107,7 +107,6 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* 100000cc 0 OBJECT LOCAL DEFAULT 8 _GLOBAL_OFFSET_TABLE_ .* 100000c0 0 NOTYPE LOCAL DEFAULT 8 __c6xabi_DSBT_BASE .* 100000e8 4 OBJECT GLOBAL DEFAULT 9 b -.* 00020000 0 OBJECT GLOBAL DEFAULT ABS __stacksize .* 00000000 0 NOTYPE WEAK DEFAULT UND g1 .* 100000e4 4 OBJECT GLOBAL DEFAULT 9 g2 .* 10000008 52 FUNC GLOBAL DEFAULT 7 sub0 diff --git a/ld/testsuite/ld-tic6x/static-app-1b.rd b/ld/testsuite/ld-tic6x/static-app-1b.rd index ae5bc8d..c56d637 100644 --- a/ld/testsuite/ld-tic6x/static-app-1b.rd +++ b/ld/testsuite/ld-tic6x/static-app-1b.rd @@ -107,7 +107,6 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* 100000cc 0 OBJECT LOCAL DEFAULT 8 _GLOBAL_OFFSET_TABLE_ .* 100000c0 0 NOTYPE LOCAL DEFAULT 8 __c6xabi_DSBT_BASE .* 100000e8 4 OBJECT GLOBAL DEFAULT 9 b -.* 00020000 0 OBJECT GLOBAL DEFAULT ABS __stacksize .* 00000000 0 NOTYPE WEAK DEFAULT UND g1 .* 100000e4 4 OBJECT GLOBAL DEFAULT 9 g2 .* 10000008 52 FUNC GLOBAL DEFAULT 7 sub0 diff --git a/ld/testsuite/ld-tic6x/static-app-1r.rd b/ld/testsuite/ld-tic6x/static-app-1r.rd index 3bc91dd..588e422 100644 --- a/ld/testsuite/ld-tic6x/static-app-1r.rd +++ b/ld/testsuite/ld-tic6x/static-app-1r.rd @@ -104,7 +104,6 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* 100000cc 0 OBJECT LOCAL DEFAULT 8 _GLOBAL_OFFSET_TABLE_ .* 100000c0 0 NOTYPE LOCAL DEFAULT 8 __c6xabi_DSBT_BASE .* 100000e8 4 OBJECT GLOBAL DEFAULT 9 b -.* 00020000 0 OBJECT GLOBAL DEFAULT ABS __stacksize .* 00000000 0 NOTYPE WEAK DEFAULT UND g1 .* 100000e4 4 OBJECT GLOBAL DEFAULT 9 g2 .* 10000008 52 FUNC GLOBAL DEFAULT 7 sub0 diff --git a/ld/testsuite/ld-tic6x/static-app-1rb.rd b/ld/testsuite/ld-tic6x/static-app-1rb.rd index 3bc91dd..588e422 100644 --- a/ld/testsuite/ld-tic6x/static-app-1rb.rd +++ b/ld/testsuite/ld-tic6x/static-app-1rb.rd @@ -104,7 +104,6 @@ Symbol table '\.symtab' contains [0-9]+ entries: .* 100000cc 0 OBJECT LOCAL DEFAULT 8 _GLOBAL_OFFSET_TABLE_ .* 100000c0 0 NOTYPE LOCAL DEFAULT 8 __c6xabi_DSBT_BASE .* 100000e8 4 OBJECT GLOBAL DEFAULT 9 b -.* 00020000 0 OBJECT GLOBAL DEFAULT ABS __stacksize .* 00000000 0 NOTYPE WEAK DEFAULT UND g1 .* 100000e4 4 OBJECT GLOBAL DEFAULT 9 g2 .* 10000008 52 FUNC GLOBAL DEFAULT 7 sub0 |