X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=ld%2Femultempl%2Faix.em;h=56985cfa753efe2e695d886924c1bcb7ba58b38c;hb=74fffc39827629fb48c9e24a7d12ebbd5693df4b;hp=d374c0c300348d48413d11cb7faf604c1fe04a0b;hpb=ced323bd49a2e0fec0876af4695893bb96b90049;p=deliverable%2Fbinutils-gdb.git diff --git a/ld/emultempl/aix.em b/ld/emultempl/aix.em index d374c0c300..56985cfa75 100644 --- a/ld/emultempl/aix.em +++ b/ld/emultempl/aix.em @@ -9,9 +9,7 @@ fragment < AIX support by Ian Lance Taylor AIX 64 bit support by Tom Rix @@ -145,7 +143,7 @@ gld${EMULATION_NAME}_before_parse (void) { ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`); - config.dynamic_link = TRUE; + input_flags.dynamic = TRUE; config.has_shared = TRUE; /* The link_info.[init|fini]_functions are initialized in ld/lexsup.c. @@ -259,7 +257,7 @@ gld${EMULATION_NAME}_add_options {NULL, no_argument, NULL, 0} }; - /* Options supported by the AIX linker which we do not support: -f, + /* Options supported by the AIX linker which we do not support: -S, -v, -Z, -bbindcmds, -bbinder, -bbindopts, -bcalls, -bcaps, -bcror15, -bdebugopt, -bdbg, -bdelcsect, -bex?, -bfilelist, -bfl, -bgcbypass, -bglink, -binsert, -bi, -bloadmap, -bl, -bmap, -bnl, @@ -303,6 +301,76 @@ gld${EMULATION_NAME}_parse_args (int argc, char **argv) return FALSE; } +/* Helper for option '-f', which specify a list of input files. + Contrary to the native linker, we don't support shell patterns + (simply because glob isn't always available). */ + +static void +read_file_list (const char *filename) +{ + FILE *f; + /* An upper bound on the number of characters in the file. */ + long pos; + /* File in memory. */ + char *buffer; + size_t len; + char *b; + char *e; + + f = fopen (filename, FOPEN_RT); + if (f == NULL) + { + einfo ("%F%P: cannot open %s\n", filename); + return; + } + if (fseek (f, 0L, SEEK_END) == -1) + goto error; + pos = ftell (f); + if (pos == -1) + goto error; + if (fseek (f, 0L, SEEK_SET) == -1) + goto error; + + buffer = (char *) xmalloc (pos + 1); + len = fread (buffer, sizeof (char), pos, f); + if (len != (size_t) pos && ferror (f)) + goto error; + /* Add a NUL terminator. */ + buffer[len] = '\0'; + fclose (f); + + /* Parse files. */ + b = buffer; + while (1) + { + /* Skip empty lines. */ + while (*b == '\n' || *b == '\r') + b++; + + /* Stop if end of buffer. */ + if (b == buffer + len) + break; + + /* Eat any byte until end of line. */ + for (e = b; *e != '\0'; e++) + if (*e == '\n' || *e == '\r') + break; + + /* Replace end of line by nul. */ + if (*e != '\0') + *e++ = '\0'; + + if (b != e) + lang_add_input_file (b, lang_input_file_is_search_file_enum, NULL); + b = e; + } + return; + + error: + einfo ("%F%P: cannot read %s\n", optarg); + fclose (f); +} + static bfd_boolean gld${EMULATION_NAME}_handle_option (int optc) { @@ -318,6 +386,12 @@ gld${EMULATION_NAME}_handle_option (int optc) /* Long option which just sets a flag. */ break; + case 'f': + /* This overrides --auxiliary. This option specifies a file containing + a list of input files. */ + read_file_list (optarg); + break; + case 'D': val = bfd_scan_vma (optarg, &end, 0); if (*end != '\0') @@ -593,7 +667,7 @@ gld${EMULATION_NAME}_unrecognized_file (lang_input_statement_type *entry) *flpp = n; ret = TRUE; - entry->loaded = TRUE; + entry->flags.loaded = TRUE; } fclose (e); @@ -780,7 +854,7 @@ gld${EMULATION_NAME}_before_allocation (void) /* Remove this section from the list of the output section. This assumes we know what the script looks like. */ is = NULL; - os = lang_output_section_find (sec->output_section->name); + os = lang_output_section_get (sec->output_section); if (os == NULL) einfo ("%P%F: can't find output section %s\n", sec->output_section->name); @@ -1034,6 +1108,7 @@ gld${EMULATION_NAME}_read_file (const char *filename, bfd_boolean import) { bfd_set_error (bfd_error_system_call); einfo ("%F%s: %E\n", filename); + return; } keep = FALSE; @@ -1238,6 +1313,8 @@ gld${EMULATION_NAME}_read_file (const char *filename, bfd_boolean import) obstack_free (o, NULL); free (o); } + + fclose (f); } /* This routine saves us from worrying about declaring free. */ @@ -1322,7 +1399,7 @@ static char * gld${EMULATION_NAME}_get_script (int *isfile) EOF -if test -n "$COMPILE_IN" +if test x"$COMPILE_IN" = xyes then # Scripts compiled in. @@ -1429,10 +1506,16 @@ gld${EMULATION_NAME}_open_dynamic_archive (const char *arch, { char *path; - if (!entry->maybe_archive) + if (!entry->flags.maybe_archive) return FALSE; - path = concat (search->name, "/lib", entry->filename, arch, ".a", NULL); + if (entry->flags.full_name_provided) + path = concat (search->name, "/", entry->filename, + (const char *) NULL); + else + path = concat (search->name, "/lib", entry->filename, arch, ".a", + (const char *) NULL); + if (!ldfile_try_open_bfd (path, entry)) { free (path); @@ -1470,6 +1553,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = { NULL, /* list_options */ NULL, /* recognized_file */ NULL, /* find potential_libraries */ - NULL /* new_vers_pattern */ + NULL, /* new_vers_pattern */ + NULL /* extra_map_file_text */ }; EOF