[PATCH, GOLD, AArch64] default stack not executable
Jim Wilson
jim.wilson@linaro.org
Thu Sep 21 20:35:00 GMT 2017
Testcase attached.
On Thu, Sep 21, 2017 at 1:26 PM, Jim Wilson <jim.wilson@linaro.org> wrote:
> For aarch64, ld.bfd makes the stack not executable when a GNU-stack note is
> missing. Note that elf_backend_default_execstack is 0 in bfd/elfnn-aarch64.c.
>
> However, ld.gold makes the stack executable when a GNU-stack note is missing.
> Note that is_default_stack_executable is true in gold/aarch64.cc.
>
> This appears to be a bug in gold. It also looks like 64-bit ppc gets this
> wrong also, though I have not tested that.
>
> The following patch fixes this for aarch64 by changing gold aarch64 to make
> is_default_stack_executable false. This was tested with a make check, and
> there were no regressions. It was also verified against a testcase using a
> .s file with a missing GNU-stack note.
>
> gold/
> * aarch64.cc (Target_aarch64::aarch64_info): Set
> is_default_stack_executable to false.
> ---
> gold/aarch64.cc | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gold/aarch64.cc b/gold/aarch64.cc
> index a72e2c3..4c6e920 100644
> --- a/gold/aarch64.cc
> +++ b/gold/aarch64.cc
> @@ -3523,7 +3523,7 @@ const Target::Target_info Target_aarch64<64, false>::aarch64_info =
> false, // has_make_symbol
> false, // has_resolve
> false, // has_code_fill
> - true, // is_default_stack_executable
> + false, // is_default_stack_executable
> true, // can_icf_inline_merge_sections
> '\0', // wrap_char
> "/lib/ld.so.1", // program interpreter
> @@ -3551,7 +3551,7 @@ const Target::Target_info Target_aarch64<32, false>::aarch64_info =
> false, // has_make_symbol
> false, // has_resolve
> false, // has_code_fill
> - true, // is_default_stack_executable
> + false, // is_default_stack_executable
> false, // can_icf_inline_merge_sections
> '\0', // wrap_char
> "/lib/ld.so.1", // program interpreter
> @@ -3579,7 +3579,7 @@ const Target::Target_info Target_aarch64<64, true>::aarch64_info =
> false, // has_make_symbol
> false, // has_resolve
> false, // has_code_fill
> - true, // is_default_stack_executable
> + false, // is_default_stack_executable
> true, // can_icf_inline_merge_sections
> '\0', // wrap_char
> "/lib/ld.so.1", // program interpreter
> @@ -3607,7 +3607,7 @@ const Target::Target_info Target_aarch64<32, true>::aarch64_info =
> false, // has_make_symbol
> false, // has_resolve
> false, // has_code_fill
> - true, // is_default_stack_executable
> + false, // is_default_stack_executable
> false, // can_icf_inline_merge_sections
> '\0', // wrap_char
> "/lib/ld.so.1", // program interpreter
> --
> 2.7.4
>
-------------- next part --------------
weathertop:2106$ cat tmp2.s
.comm i,4,4
weathertop:2107$ cd bin
weathertop:2108$ rm ld
weathertop:2109$ ln -s ld.bfd ld
weathertop:2110$ cd ..
weathertop:2111$ gcc -Bbin/ tmp.c tmp2.s
weathertop:2112$ readelf -l a.out
Elf file type is EXEC (Executable file)
Entry point 0x400410
There are 8 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000400040 0x0000000000400040
0x00000000000001c0 0x00000000000001c0 R E 8
INTERP 0x0000000000000200 0x0000000000400200 0x0000000000400200
0x000000000000001b 0x000000000000001b R 1
[Requesting program interpreter: /lib/ld-linux-aarch64.so.1]
LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000
0x00000000000005fc 0x00000000000005fc R E 10000
LOAD 0x0000000000000df0 0x0000000000410df0 0x0000000000410df0
0x0000000000000238 0x0000000000000240 RW 10000
DYNAMIC 0x0000000000000e08 0x0000000000410e08 0x0000000000410e08
0x00000000000001d0 0x00000000000001d0 RW 8
NOTE 0x000000000000021c 0x000000000040021c 0x000000000040021c
0x0000000000000044 0x0000000000000044 R 4
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 10
GNU_RELRO 0x0000000000000df0 0x0000000000410df0 0x0000000000410df0
0x0000000000000210 0x0000000000000210 R 1
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame
03 .init_array .fini_array .jcr .dynamic .got .got.plt .data .bss
04 .dynamic
05 .note.ABI-tag .note.gnu.build-id
06
07 .init_array .fini_array .jcr .dynamic .got
weathertop:2113$ cd bin
weathertop:2114$ rm ld
weathertop:2115$ ln -s ld.gold ld
weathertop:2116$ cd ..
weathertop:2117$ gcc -Bbin/ tmp.c tmp2.s
weathertop:2118$ readelf -l a.out
Elf file type is EXEC (Executable file)
Entry point 0x4004e0
There are 9 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000400040 0x0000000000400040
0x00000000000001f8 0x00000000000001f8 R 8
INTERP 0x0000000000000238 0x0000000000400238 0x0000000000400238
0x000000000000001b 0x000000000000001b R 1
[Requesting program interpreter: /lib/ld-linux-aarch64.so.1]
LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000
0x00000000000006d4 0x00000000000006d4 R E 10000
LOAD 0x000000000000fdf0 0x000000000041fdf0 0x000000000041fdf0
0x0000000000000238 0x0000000000000240 RW 10000
DYNAMIC 0x000000000000fe08 0x000000000041fe08 0x000000000041fe08
0x00000000000001d0 0x00000000000001d0 RW 8
NOTE 0x0000000000000254 0x0000000000400254 0x0000000000400254
0x0000000000000044 0x0000000000000044 R 4
GNU_EH_FRAME 0x00000000000006cc 0x00000000004006cc 0x00000000004006cc
0x0000000000000008 0x0000000000000008 R 4
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RWE 10
GNU_RELRO 0x000000000000fdf0 0x000000000041fdf0 0x000000000041fdf0
0x0000000000000210 0x0000000000000210 RW 8
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.ABI-tag .note.gnu.build-id .dynsym .dynstr .gnu.hash .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame .eh_frame_hdr
03 .jcr .fini_array .init_array .dynamic .got .got.plt .data .bss
04 .dynamic
05 .note.ABI-tag .note.gnu.build-id
06 .eh_frame_hdr
07
08 .jcr .fini_array .init_array .dynamic .got
weathertop:2119$
More information about the Binutils
mailing list