This adds support for Sun's DT_CONFIG entry in the .dynamic section. On Solaris this is used to set the linker configuration file on a per binary basis. The config path is specified on the command-line with either the -config or -C options plus an argument. CMO/20080907 diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 317d32e..d008f57 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -701,8 +701,8 @@ extern struct bfd_link_needed_list *bfd_elf_get_needed_list extern bfd_boolean bfd_elf_get_bfd_needed_list (bfd *, struct bfd_link_needed_list **); extern bfd_boolean bfd_elf_size_dynamic_sections - (bfd *, const char *, const char *, const char *, const char * const *, - struct bfd_link_info *, struct bfd_section **, + (bfd *, const char *, const char *, const char *, const char *, + const char * const *, struct bfd_link_info *, struct bfd_section **, struct bfd_elf_version_tree *); extern bfd_boolean bfd_elf_size_dynsym_hash_dynstr (bfd *, struct bfd_link_info *); diff --git a/bfd/elflink.c b/bfd/elflink.c index 6059ab1..d6d2af1 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -3155,6 +3155,7 @@ elf_finalize_dynstr (bfd *output_bfd, struct bfd_link_info *info) break; case DT_NEEDED: case DT_SONAME: + case DT_CONFIG: case DT_RPATH: case DT_RUNPATH: case DT_FILTER: @@ -5307,6 +5308,7 @@ compute_bucket_count (struct bfd_link_info *info, unsigned long int *hashcodes, bfd_boolean bfd_elf_size_dynamic_sections (bfd *output_bfd, const char *soname, + const char *config, const char *rpath, const char *filter_shlib, const char * const *auxiliary_filters, @@ -5315,6 +5317,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_elf_version_tree *verdefs) { bfd_size_type soname_indx; + bfd_size_type config_indx; bfd *dynobj; const struct elf_backend_data *bed; struct elf_assign_sym_version_info asvinfo; @@ -5322,6 +5325,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, *sinterpptr = NULL; soname_indx = (bfd_size_type) -1; + config_indx = (bfd_size_type) -1; if (!is_elf_hash_table (info->hash)) return TRUE; @@ -5410,6 +5414,15 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, return FALSE; } + if (config != NULL) + { + config_indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, + config, TRUE); + if (config_indx == (bfd_size_type) -1 + || !_bfd_elf_add_dynamic_entry (info, DT_CONFIG, config_indx)) + return FALSE; + } + if (info->symbolic) { if (!_bfd_elf_add_dynamic_entry (info, DT_SYMBOLIC, 0)) @@ -5757,7 +5770,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, + sizeof (Elf_External_Verdaux)); } - if (soname_indx != (bfd_size_type) -1) + if (soname_indx != (bfd_size_type) -1) { _bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, soname_indx); diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index d60d4dd..2d107cf 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1401,8 +1401,8 @@ gld${EMULATION_NAME}_before_allocation (void) if (rpath == NULL) rpath = (const char *) getenv ("LD_RUN_PATH"); if (! (bfd_elf_size_dynamic_sections - (output_bfd, command_line.soname, rpath, - command_line.filter_shlib, + (output_bfd, command_line.soname, command_line.config, + rpath, command_line.filter_shlib, (const char * const *) command_line.auxiliary_filters, &link_info, &sinterp, lang_elf_version_info))) einfo ("%P%F: failed to set dynamic section sizes: %E\n"); diff --git a/ld/ld.h b/ld/ld.h index 69371df..cf35f7f 100644 --- a/ld/ld.h +++ b/ld/ld.h @@ -202,6 +202,9 @@ typedef struct { /* Name to give runtime libary from the -soname argument. */ char *soname; + /* Dynamic linker configuration file from the -config argument. */ + char *config; + /* Runtime library search path from the -rpath argument. */ char *rpath; diff --git a/ld/lexsup.c b/ld/lexsup.c index 2a31683..0f263f4 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -68,6 +68,7 @@ enum option_values { OPTION_ASSERT = 150, OPTION_CALL_SHARED, + OPTION_CONFIG, OPTION_CREF, OPTION_DEFSYM, OPTION_DEMANGLE, @@ -236,6 +237,8 @@ static const struct ld_option ld_options[] = TWO_DASHES }, { {"soname", required_argument, NULL, OPTION_SONAME}, 'h', N_("FILENAME"), N_("Set internal name of shared library"), ONE_DASH }, + { {"config", required_argument, NULL, OPTION_CONFIG}, + 'C', N_("FILENAME"), N_("Set dynamic linker config file"), ONE_DASH }, { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER}, 'I', N_("PROGRAM"), N_("Set PROGRAM as the dynamic linker to use"), TWO_DASHES }, @@ -752,6 +755,9 @@ parse_args (unsigned argc, char **argv) case OPTION_NON_SHARED: config.dynamic_link = FALSE; break; + case OPTION_CONFIG: + command_line.config = optarg; + break; case OPTION_CREF: command_line.cref = TRUE; link_info.notice_all = TRUE;