From 5fe2850dd96483f176858fd75c098313d5b20bc2 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 22 Sep 2015 06:08:55 -0700 Subject: [PATCH] Set DF_1_PIE in gld${EMULATION_NAME}_after_parse We can't add OPTION_PIE to gld${EMULATION_NAME}_handle_option since it has been handled in parse_args in lexsup.c. This patch moves setting DF_1_PIE to gld${EMULATION_NAME}_after_parse. ld/ * emultempl/alphaelf.em (alpha_after_parse): Call gld${EMULATION_NAME}_after_parse instead of after_parse_default. * emultempl/cr16elf.em (cr16elf_after_parse): Likewise. * emultempl/crxelf.em (crxelf_after_parse); Likewise. * emultempl/hppaelf.em (hppaelf_after_parse): Likewise. * emultempl/mipself.em (mips_after_parse): Likewise. * emultempl/nds32elf.em (nds32_elf_after_parse): Likewise. * emultempl/elf32.em: Don't include ldlex.h. (gld${EMULATION_NAME}_after_parse): New function. (gld${EMULATION_NAME}_handle_option) [GENERATE_PIE_SCRIPT] : Removed. (ld_${EMULATION_NAME}_emulation): Replace after_parse_default with gld${EMULATION_NAME}_after_parse. * emultempl/ia64elf.em (gld${EMULATION_NAME}_after_parse): Renamed to ... (ia64elf_after_parse): This. Call gld${EMULATION_NAME}_after_parse instead of after_parse_default. (LDEMUL_AFTER_PARSE): Replace gld${EMULATION_NAME}_after_parse with ia64elf_after_parse. ld/testsuite/ * ld-elf/pie.d: New test. --- ld/ChangeLog | 23 +++++++++++++++++++++++ ld/emultempl/alphaelf.em | 2 +- ld/emultempl/cr16elf.em | 2 +- ld/emultempl/crxelf.em | 2 +- ld/emultempl/elf32.em | 26 +++++++++++++++++--------- ld/emultempl/hppaelf.em | 2 +- ld/emultempl/ia64elf.em | 6 +++--- ld/emultempl/mipself.em | 2 +- ld/emultempl/nds32elf.em | 2 +- ld/testsuite/ChangeLog | 4 ++++ ld/testsuite/ld-elf/pie.d | 8 ++++++++ 11 files changed, 61 insertions(+), 18 deletions(-) create mode 100644 ld/testsuite/ld-elf/pie.d diff --git a/ld/ChangeLog b/ld/ChangeLog index 88a46c5..93a852a 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,26 @@ +2015-09-22 H.J. Lu + + * emultempl/alphaelf.em (alpha_after_parse): Call + gld${EMULATION_NAME}_after_parse instead of + after_parse_default. + * emultempl/cr16elf.em (cr16elf_after_parse): Likewise. + * emultempl/crxelf.em (crxelf_after_parse); Likewise. + * emultempl/hppaelf.em (hppaelf_after_parse): Likewise. + * emultempl/mipself.em (mips_after_parse): Likewise. + * emultempl/nds32elf.em (nds32_elf_after_parse): Likewise. + * emultempl/elf32.em: Don't include ldlex.h. + (gld${EMULATION_NAME}_after_parse): New function. + (gld${EMULATION_NAME}_handle_option) [GENERATE_PIE_SCRIPT] + : Removed. + (ld_${EMULATION_NAME}_emulation): Replace after_parse_default + with gld${EMULATION_NAME}_after_parse. + * emultempl/ia64elf.em (gld${EMULATION_NAME}_after_parse): + Renamed to ... + (ia64elf_after_parse): This. Call + gld${EMULATION_NAME}_after_parse instead of after_parse_default. + (LDEMUL_AFTER_PARSE): Replace gld${EMULATION_NAME}_after_parse + with ia64elf_after_parse. + 2015-09-22 Rainer Orth * emulparams/solaris2.sh (GENERATE_PIE_SCRIPT): Set to yes. diff --git a/ld/emultempl/alphaelf.em b/ld/emultempl/alphaelf.em index 1301c6f..1db94c7 100644 --- a/ld/emultempl/alphaelf.em +++ b/ld/emultempl/alphaelf.em @@ -82,7 +82,7 @@ alpha_after_parse (void) exp_nameop (SIZEOF_HEADERS, NULL)), NULL); - after_parse_default (); + gld${EMULATION_NAME}_after_parse (); } static void diff --git a/ld/emultempl/cr16elf.em b/ld/emultempl/cr16elf.em index 276dce4..48dcf14 100644 --- a/ld/emultempl/cr16elf.em +++ b/ld/emultempl/cr16elf.em @@ -119,7 +119,7 @@ cr16elf_after_parse (void) is true the link sometimes fails. */ config.magic_demand_paged = FALSE; - after_parse_default (); + gld${EMULATION_NAME}_after_parse (); } /* This is called after the sections have been attached to output diff --git a/ld/emultempl/crxelf.em b/ld/emultempl/crxelf.em index 8fefb82..172aa9b 100644 --- a/ld/emultempl/crxelf.em +++ b/ld/emultempl/crxelf.em @@ -42,7 +42,7 @@ crxelf_after_parse (void) is true the link sometimes fails. */ config.magic_demand_paged = FALSE; - after_parse_default (); + gld${EMULATION_NAME}_after_parse (); } /* This is called after the sections have been attached to output diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 5fe576e..b7ddca3 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -49,7 +49,6 @@ fragment < + + * ld-elf/pie.d: New test. + 2015-09-18 Alan Modra PR ld/18963 diff --git a/ld/testsuite/ld-elf/pie.d b/ld/testsuite/ld-elf/pie.d new file mode 100644 index 0000000..d68b962 --- /dev/null +++ b/ld/testsuite/ld-elf/pie.d @@ -0,0 +1,8 @@ +#source: start.s +#readelf: -d -W +#ld: -pie +#target: *-*-linux* *-*-gnu* *-*-solaris* + +#... + +0x[0-9a-f]+ +\(FLAGS_1\) +Flags: +PIE +#pass -- 2.7.4