aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl/elf32.em
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2004-03-18 12:50:20 +0000
committerAlan Modra <amodra@gmail.com>2004-03-18 12:50:20 +0000
commit4a43e768f18f325a0e52de37fe69d4a6a764d668 (patch)
tree5fed3b135f3382db0391e56136eefc09e32929a0 /ld/emultempl/elf32.em
parent3e4caed2b120cd3930d19c96fc5761f9254946c5 (diff)
downloadgdb-4a43e768f18f325a0e52de37fe69d4a6a764d668.zip
gdb-4a43e768f18f325a0e52de37fe69d4a6a764d668.tar.gz
gdb-4a43e768f18f325a0e52de37fe69d4a6a764d668.tar.bz2
bfd/
* elf-bfd.h (struct elf_obj_tdata): Delete dt_soname field. Add dyn_lib_class field. Rearrange for better packing. (elf_dt_soname): Delete. (elf_dyn_lib_class): Define. * elf.c (bfd_elf_set_dt_needed_name): Update comment. (bfd_elf_set_dt_needed_soname): Delete. (bfd_elf_set_dyn_lib_class): New function. * elflink.h (add_dt_needed_tag): New function. Split out from.. (elf_link_add_object_symbols): ..here. Rename "name" to "soname". Use elf_dyn_lib_class to set dt_needed and add_needed. Move fallback initialization of soname. (elf_link_check_versioned_symbol): Test elf_dyn_lib_class instead of elf_dt_soname. * bfd-in.h (enum dynamic_lib_link_class): New. (bfd_elf_set_dt_needed_soname): Delete. (bfd_elf_set_dyn_lib_class): Declare. * bfd-in2.h: Regenerate. ld/ * ld.texinfo: Add --as-needed doco. * ldmain.c (as_needed): New global var. * ldmain.h (as_needed): Declare. * lexsup.c (option_values): Add OPTION_AS_NEEDED and OPTION_NO_AS_NEEDED. (ld_options): Likewise. (parse_args): Handle them. * ldlang.h (lang_input_statement_type): Add as_needed field. * ldlang.c (new_afile): Set p->as_needed. * emultempl/elf32.em (gld${EMULATION_NAME}_load_symbols): New function. (gld${EMULATION_NAME}_try_needed): Use bfd_elf_set_dyn_lib_class. (ld_${EMULATION_NAME}_emulation): Set LDEMUL_RECOGNIZED_FILE entry. * ldlang.c (open_input_bfds): Remove useless cast. (lang_do_assignments_1): Likewise. (lang_for_each_input_section): Delete.
Diffstat (limited to 'ld/emultempl/elf32.em')
-rw-r--r--ld/emultempl/elf32.em37
1 files changed, 29 insertions, 8 deletions
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 45749e7..e95b3a9 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -89,6 +89,28 @@ gld${EMULATION_NAME}_before_parse (void)
EOF
fi
+if test x"$LDEMUL_RECOGNIZED_FILE" != xgld"${EMULATION_NAME}"_load_symbols; then
+cat >>e${EMULATION_NAME}.c <<EOF
+/* Handle as_needed DT_NEEDED. */
+
+static bfd_boolean
+gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *entry)
+{
+ if (!entry->as_needed
+ || (bfd_get_file_flags (entry->the_bfd) & DYNAMIC) == 0)
+ return FALSE;
+
+ /* Tell the ELF linker that we don't want the output file to have a
+ DT_NEEDED entry for this file, unless it is used to resolve
+ references in a regular object. */
+ bfd_elf_set_dyn_lib_class (entry->the_bfd, DYN_AS_NEEDED);
+
+ /* Continue on with normal load_symbols processing. */
+ return FALSE;
+}
+EOF
+fi
+
cat >>e${EMULATION_NAME}.c <<EOF
/* These variables are required to pass information back and forth
@@ -336,14 +358,13 @@ cat >>e${EMULATION_NAME}.c <<EOF
return TRUE;
}
- /* Tell the ELF backend that we don't want the output file to have a
- DT_NEEDED entry for this file. */
- bfd_elf_set_dt_needed_name (abfd, "");
+ /* Specify the soname to use. */
+ bfd_elf_set_dt_needed_name (abfd, soname);
- /* Tell the ELF backend that the output file needs a DT_NEEDED
- entry for this file if it is used to resolve the reference in
- a regular object. */
- bfd_elf_set_dt_needed_soname (abfd, soname);
+ /* Tell the ELF linker that we don't want the output file to have a
+ DT_NEEDED entry for this file, unless it is used to resolve
+ references in a regular object. */
+ bfd_elf_set_dyn_lib_class (abfd, DYN_DT_NEEDED);
/* Add this file into the symbol table. */
if (! bfd_link_add_symbols (abfd, &link_info))
@@ -1752,7 +1773,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
gld${EMULATION_NAME}_handle_option,
${LDEMUL_UNRECOGNIZED_FILE-NULL},
${LDEMUL_LIST_OPTIONS-gld${EMULATION_NAME}_list_options},
- ${LDEMUL_RECOGNIZED_FILE-NULL},
+ ${LDEMUL_RECOGNIZED_FILE-gld${EMULATION_NAME}_load_symbols},
${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL},
${LDEMUL_NEW_VERS_PATTERN-NULL}
};