This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PATCH: Fix ia64 relaxation regression
On Fri, May 27, 2005 at 05:15:18PM -0700, H. J. Lu wrote:
> On Fri, May 27, 2005 at 04:09:00PM -0700, H. J. Lu wrote:
> > This is caused by not defining array bonds in elf.sc. The problem
> > is when bfd_elf_size_dynamic_sections is called by
> > gld${EMULATION_NAME}_before_allocation. Those symbols are undefined.
> > As the result, bfd_elf_size_dynamic_sections will allocate
> > dynamic relocations for them, which leads to extra R_X86_64_NONE and
> > DT_TEXTREL on x86-64. On ia64, we got some R_IA64_REL64LSB instead of
> > R_IA64_NONE.
> >
>
> This fixed PR 975. I will look into ia64 later. BTW, gcc needs the fix
> for:
>
The gld${EMULATION_NAME}_provide_init_fini_syms change caused the ia64
relaxation regression since the values of those symbols aren't
available during relaxation. This patch adds ldemul_provide_symbols and
calls it from lang_do_assignments.
H.J.
-----
bfd/
2005-05-31 H.J. Lu <hongjiu.lu@intel.com>
* elf-bfd.h (elf_link_hash_entry): Add the provide field.
* elflink.c (bfd_elf_set_symbol): Set the provide field to 1.
(_bfd_elf_provide_section_bound_symbols): Also provide the
symbol if the provide field is non-zero.
ld/
2005-05-31 H.J. Lu <hongjiu.lu@intel.com>
* emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Set to the
provide_symbols field to NULL.
* emultempl/armcoff.em: Likewise.
* emultempl/beos.em: Likewise.
* emultempl/generic.em: Likewise.
* emultempl/gld960.em: Likewise.
* emultempl/gld960c.em: Likewise.
* emultempl/linux.em: Likewise.
* emultempl/lnk960.em: Likewise.
* emultempl/m68kcoff.em: Likewise.
* emultempl/pe.em: Likewise.
* emultempl/sunos.em: Likewise.
* emultempl/ticoff.em: Likewise.
* emultempl/vanilla.em: Likewise.
* emultempl/elf32.em (gld${EMULATION_NAME}_provide_init_fini_syms):
Renamd to ...
(gld${EMULATION_NAME}_provide_symbols): This.
* emultempl/elf32.em (gld${EMULATION_NAME}_finish): Remove call
to gld${EMULATION_NAME}_provide_init_fini_syms.
* emultempl/hppaelf.em: Likewise.
* emultempl/ppc64elf.em: Likewise.
* ldemul.c (ldemul_provide_symbols): New.
* ldemul.h (ldemul_provide_symbols): New.
(ld_emulation_xfer_struct): Add the provide_symbols field.
* ldlang.c (lang_do_assignments): Call ldemul_provide_symbols.
--- binutils/bfd/elf-bfd.h.provide 2005-05-25 06:51:23.000000000 -0700
+++ binutils/bfd/elf-bfd.h 2005-05-31 11:17:38.000000000 -0700
@@ -170,6 +170,10 @@ struct elf_link_hash_entry
matters. */
unsigned int pointer_equality_needed : 1;
+ /* Symbol is provided by linker emulation. */
+ unsigned int provide: 1;
+
+ /* Symbol is referenced by a shared object. */
/* String table index in .dynstr if this is a dynamic symbol. */
unsigned long dynstr_index;
--- binutils/bfd/elflink.c.provide 2005-05-31 10:52:33.000000000 -0700
+++ binutils/bfd/elflink.c 2005-05-31 11:01:35.000000000 -0700
@@ -9833,6 +9833,7 @@ bfd_elf_set_symbol (struct elf_link_hash
h->root.u.def.section = bfd_abs_section_ptr;
h->root.u.def.value = val;
h->def_regular = 1;
+ h->provide = 1;
h->type = STT_OBJECT;
h->other = STV_HIDDEN | (h->other & ~ ELF_ST_VISIBILITY (-1));
h->forced_local = 1;
@@ -9870,13 +9871,15 @@ _bfd_elf_provide_section_bound_symbols (
hs = elf_link_hash_lookup (elf_hash_table (info), start, FALSE,
FALSE, FALSE);
do_start = (hs != NULL
- && (hs->root.type == bfd_link_hash_undefined
+ && (hs->provide
+ || hs->root.type == bfd_link_hash_undefined
|| hs->root.type == bfd_link_hash_undefweak));
he = elf_link_hash_lookup (elf_hash_table (info), end, FALSE,
FALSE, FALSE);
do_end = (he != NULL
- && (he->root.type == bfd_link_hash_undefined
+ && (he->provide
+ || he->root.type == bfd_link_hash_undefined
|| he->root.type == bfd_link_hash_undefweak));
if (!do_start && !do_end)
--- binutils/ld/emultempl/aix.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/aix.em 2005-05-31 11:25:51.000000000 -0700
@@ -1348,6 +1348,7 @@ struct ld_emulation_xfer_struct ld_${EMU
0, /* open_dynamic_archive */
0, /* place_orphan */
0, /* set_symbols */
+ 0, /* provide_symbols */
gld${EMULATION_NAME}_parse_args,
gld${EMULATION_NAME}_add_options,
gld${EMULATION_NAME}_handle_option,
--- binutils/ld/emultempl/armcoff.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/armcoff.em 2005-05-31 11:26:10.000000000 -0700
@@ -268,6 +268,7 @@ struct ld_emulation_xfer_struct ld_${EMU
NULL, /* open dynamic archive */
NULL, /* place orphan */
NULL, /* set symbols */
+ NULL, /* provide symbols */
NULL, /* parse_args */
gld${EMULATION_NAME}_add_options,
gld${EMULATION_NAME}_handle_option,
--- binutils/ld/emultempl/beos.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/beos.em 2005-05-31 11:26:38.000000000 -0700
@@ -790,6 +790,7 @@ struct ld_emulation_xfer_struct ld_${EMU
NULL, /* open dynamic archive */
gld${EMULATION_NAME}_place_orphan,
gld_${EMULATION_NAME}_set_symbols,
+ NULL, /* provide_symbols */
NULL, /* parse_args */
gld${EMULATION_NAME}_add_options,
gld${EMULATION_NAME}_handle_option,
--- binutils/ld/emultempl/elf32.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/elf32.em 2005-05-31 11:24:36.000000000 -0700
@@ -62,7 +62,7 @@ static bfd_boolean gld${EMULATION_NAME}_
(lang_input_statement_type *file, asection *s);
static void gld${EMULATION_NAME}_layout_sections_again (void);
static void gld${EMULATION_NAME}_strip_empty_sections (void);
-static void gld${EMULATION_NAME}_provide_init_fini_syms (void);
+static void gld${EMULATION_NAME}_provide_symbols (void);
static void gld${EMULATION_NAME}_finish (void) ATTRIBUTE_UNUSED;
EOF
@@ -1475,7 +1475,7 @@ gld${EMULATION_NAME}_provide_bound_symbo
section alignment affecting where the section starts. */
static void
-gld${EMULATION_NAME}_provide_init_fini_syms (void)
+gld${EMULATION_NAME}_provide_symbols (void)
{
if (!link_info.relocatable && link_info.executable)
{
@@ -1543,7 +1543,6 @@ gld${EMULATION_NAME}_finish (void)
gld${EMULATION_NAME}_layout_sections_again ();
gld${EMULATION_NAME}_strip_empty_sections ();
- gld${EMULATION_NAME}_provide_init_fini_syms ();
}
EOF
fi
@@ -1922,6 +1921,7 @@ struct ld_emulation_xfer_struct ld_${EMU
${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive},
${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan},
${LDEMUL_SET_SYMBOLS-NULL},
+ ${LDEMUL_PROVIDE_SYMBOLS-gld${EMULATION_NAME}_provide_symbols},
${LDEMUL_PARSE_ARGS-NULL},
gld${EMULATION_NAME}_add_options,
gld${EMULATION_NAME}_handle_option,
--- binutils/ld/emultempl/generic.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/generic.em 2005-05-31 11:27:00.000000000 -0700
@@ -136,6 +136,7 @@ struct ld_emulation_xfer_struct ld_${EMU
${LDEMUL_OPEN_DYNAMIC_ARCHIVE-NULL},
${LDEMUL_PLACE_ORPHAN-NULL},
${LDEMUL_SET_SYMBOLS-NULL},
+ ${LDEMUL_PROVIDE_SYMBOLS-NULL},
${LDEMUL_PARSE_ARGS-NULL},
NULL, /* add_options */
NULL, /* handle_option */
--- binutils/ld/emultempl/gld960.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/gld960.em 2005-05-31 11:27:20.000000000 -0700
@@ -142,6 +142,7 @@ struct ld_emulation_xfer_struct ld_gld96
NULL, /* open dynamic archive */
NULL, /* place orphan */
NULL, /* set symbols */
+ NULL, /* provide symbols */
NULL, /* parse args */
NULL, /* add_options */
NULL, /* handle_option */
--- binutils/ld/emultempl/gld960c.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/gld960c.em 2005-05-31 11:27:11.000000000 -0700
@@ -157,6 +157,7 @@ struct ld_emulation_xfer_struct ld_gld96
NULL, /* open dynamic archive */
NULL, /* place orphan */
NULL, /* set symbols */
+ NULL, /* provide symbols */
NULL, /* parse args */
NULL, /* add_options */
NULL, /* handle_option */
--- binutils/ld/emultempl/hppaelf.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/hppaelf.em 2005-05-31 11:29:58.000000000 -0700
@@ -306,7 +306,6 @@ hppaelf_finish (void)
}
gld${EMULATION_NAME}_strip_empty_sections ();
- gld${EMULATION_NAME}_provide_init_fini_syms ();
}
--- binutils/ld/emultempl/linux.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/linux.em 2005-05-31 11:27:42.000000000 -0700
@@ -197,6 +197,7 @@ struct ld_emulation_xfer_struct ld_${EMU
gld${EMULATION_NAME}_open_dynamic_archive,
NULL, /* place orphan */
NULL, /* set symbols */
+ NULL, /* provide symbols */
NULL, /* parse args */
NULL, /* add_options */
NULL, /* handle_option */
--- binutils/ld/emultempl/lnk960.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/lnk960.em 2005-05-31 11:27:52.000000000 -0700
@@ -277,6 +277,7 @@ struct ld_emulation_xfer_struct ld_lnk96
NULL, /* open dynamic archive */
NULL, /* place orphan */
NULL, /* set symbols */
+ NULL, /* provide symbols */
NULL, /* parse args */
NULL, /* add_options */
NULL, /* handle_option */
--- binutils/ld/emultempl/m68kcoff.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/m68kcoff.em 2005-05-31 11:28:08.000000000 -0700
@@ -230,6 +230,7 @@ struct ld_emulation_xfer_struct ld_${EMU
NULL, /* open dynamic archive */
NULL, /* place orphan */
NULL, /* set symbols */
+ NULL, /* provide symbols */
NULL, /* parse args */
NULL, /* add_options */
NULL, /* handle_option */
--- binutils/ld/emultempl/pe.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/pe.em 2005-05-31 11:28:42.000000000 -0700
@@ -1830,6 +1830,7 @@ struct ld_emulation_xfer_struct ld_${EMU
gld_${EMULATION_NAME}_open_dynamic_archive,
gld_${EMULATION_NAME}_place_orphan,
gld_${EMULATION_NAME}_set_symbols,
+ NULL, /* provide_symbols */
NULL, /* parse_args */
gld${EMULATION_NAME}_add_options,
gld${EMULATION_NAME}_handle_option,
--- binutils/ld/emultempl/ppc64elf.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/ppc64elf.em 2005-05-31 11:30:03.000000000 -0700
@@ -380,7 +380,6 @@ ppc_finish (void)
ppc64_elf_restore_symbols (&link_info);
gld${EMULATION_NAME}_strip_empty_sections ();
- gld${EMULATION_NAME}_provide_init_fini_syms ();
}
--- binutils/ld/emultempl/sunos.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/sunos.em 2005-05-31 11:29:10.000000000 -0700
@@ -1021,6 +1021,7 @@ struct ld_emulation_xfer_struct ld_${EMU
NULL, /* open dynamic archive */
NULL, /* place orphan */
gld${EMULATION_NAME}_set_symbols,
+ NULL, /* provide_symbols */
NULL, /* parse args */
NULL, /* add_options */
NULL, /* handle_option */
--- binutils/ld/emultempl/ticoff.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/ticoff.em 2005-05-31 11:29:19.000000000 -0700
@@ -170,6 +170,7 @@ struct ld_emulation_xfer_struct ld_${EMU
NULL, /* open dynamic archive */
NULL, /* place orphan */
NULL, /* set_symbols */
+ NULL, /* provide_symbols */
NULL, /* parse_args */
gld${EMULATION_NAME}_add_options,
gld${EMULATION_NAME}_handle_option,
--- binutils/ld/emultempl/vanilla.em.provide 2005-05-16 11:04:41.000000000 -0700
+++ binutils/ld/emultempl/vanilla.em 2005-05-31 11:29:29.000000000 -0700
@@ -73,6 +73,7 @@ struct ld_emulation_xfer_struct ld_vanil
NULL, /* open dynamic archive */
NULL, /* place orphan */
NULL, /* set symbols */
+ NULL, /* provide symbols */
NULL, /* parse args */
NULL, /* add_options */
NULL, /* handle_option */
--- binutils/ld/ldemul.c.provide 2005-05-16 11:04:39.000000000 -0700
+++ binutils/ld/ldemul.c 2005-05-31 11:15:22.000000000 -0700
@@ -100,6 +100,13 @@ ldemul_set_symbols (void)
}
void
+ldemul_provide_symbols (void)
+{
+ if (ld_emulation->provide_symbols)
+ ld_emulation->provide_symbols ();
+}
+
+void
ldemul_create_output_section_statements (void)
{
if (ld_emulation->create_output_section_statements)
--- binutils/ld/ldemul.h.provide 2005-03-03 08:56:33.000000000 -0800
+++ binutils/ld/ldemul.h 2005-05-31 11:22:07.000000000 -0700
@@ -51,6 +51,8 @@ extern void ldemul_finish
(void);
extern void ldemul_set_symbols
(void);
+extern void ldemul_provide_symbols
+ (void);
extern void ldemul_create_output_section_statements
(void);
extern bfd_boolean ldemul_place_orphan
@@ -149,6 +151,10 @@ typedef struct ld_emulation_xfer_struct
reading the script. Used to initialize symbols used in the script. */
void (*set_symbols) (void);
+ /* Called in lang_do_assignments. Used to provide symbols by linker
+ emulation. */
+ void (*provide_symbols) (void);
+
/* Parse args which the base linker doesn't understand.
Return TRUE if the arg needs no further processing. */
bfd_boolean (*parse_args) (int, char **);
--- binutils/ld/ldlang.c.provide 2005-05-17 10:33:01.000000000 -0700
+++ binutils/ld/ldlang.c 2005-05-31 11:21:38.000000000 -0700
@@ -4682,6 +4682,9 @@ lang_do_assignments
/* Callers of exp_fold_tree need to increment this. */
lang_statement_iteration++;
lang_do_assignments_1 (s, output_section_statement, fill, dot);
+
+ /* Assign values for symbols provided by emulation. */
+ ldemul_provide_symbols ();
}
/* Fix any .startof. or .sizeof. symbols. When the assemblers see the