aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl/elf32.em
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-09-22 06:08:55 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-09-22 06:08:55 -0700
commit5fe2850dd96483f176858fd75c098313d5b20bc2 (patch)
tree74c28f6f5392fd4c940c8e38e99e0a943bc7eac5 /ld/emultempl/elf32.em
parent5c383f026242d25a3c21fdfda42e5ca218b346c8 (diff)
downloadgdb-5fe2850dd96483f176858fd75c098313d5b20bc2.zip
gdb-5fe2850dd96483f176858fd75c098313d5b20bc2.tar.gz
gdb-5fe2850dd96483f176858fd75c098313d5b20bc2.tar.bz2
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] <OPTION_PIE>: 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.
Diffstat (limited to 'ld/emultempl/elf32.em')
-rw-r--r--ld/emultempl/elf32.em26
1 files changed, 17 insertions, 9 deletions
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 <<EOF
#include "ldmain.h"
#include "ldmisc.h"
#include "ldexp.h"
-#include "ldlex.h"
#include "ldlang.h"
#include "ldfile.h"
#include "ldemul.h"
@@ -61,6 +60,7 @@ fragment <<EOF
/* Declare functions used by various EXTRA_EM_FILEs. */
static void gld${EMULATION_NAME}_before_parse (void);
+static void gld${EMULATION_NAME}_after_parse (void);
static void gld${EMULATION_NAME}_after_open (void);
static void gld${EMULATION_NAME}_before_allocation (void);
static void gld${EMULATION_NAME}_after_allocation (void);
@@ -108,6 +108,21 @@ gld${EMULATION_NAME}_before_parse (void)
EOF
fi
+if test x"$LDEMUL_AFTER_PARSE" != xgld"$EMULATION_NAME"_after_parse; then
+fragment <<EOF
+
+static void
+gld${EMULATION_NAME}_after_parse (void)
+{
+ if (bfd_link_pie (&link_info))
+ link_info.flags_1 |= (bfd_vma) DF_1_PIE;
+
+ after_parse_default ();
+}
+
+EOF
+fi
+
if test x"$LDEMUL_RECOGNIZED_FILE" != xgld"${EMULATION_NAME}"_load_symbols; then
fragment <<EOF
/* Handle the generation of DT_NEEDED tags. */
@@ -2290,13 +2305,6 @@ fragment <<EOF
EOF
fi
-if test x"$GENERATE_PIE_SCRIPT" = xyes; then
-fragment <<EOF
- case OPTION_PIE:
- link_info.flags_1 |= (bfd_vma) DF_1_PIE;
- break;
-EOF
-fi
fragment <<EOF
case 'z':
if (strcmp (optarg, "defs") == 0)
@@ -2459,7 +2467,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse},
${LDEMUL_SYSLIB-syslib_default},
${LDEMUL_HLL-hll_default},
- ${LDEMUL_AFTER_PARSE-after_parse_default},
+ ${LDEMUL_AFTER_PARSE-gld${EMULATION_NAME}_after_parse},
${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open},
${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation},
${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},