void ldfile_add_library_path (const char *name, bfd_boolean cmdline) { search_dirs_type *new_dirs; if (!cmdline && config.only_cmd_line_lib_dirs) return; new_dirs = (search_dirs_type *) xmalloc (sizeof (search_dirs_type)); new_dirs->next = NULL; new_dirs->cmdline = cmdline; *search_tail_ptr = new_dirs; search_tail_ptr = &new_dirs->next; /* If a directory is marked as honoring sysroot, prepend the sysroot path now. */ if (name[0] == '=') { new_dirs->name = concat (ld_sysroot, name + 1, (const char *) NULL); new_dirs->sysrooted = TRUE; } else { new_dirs->name = xstrdup (name); new_dirs->sysrooted = is_sysrooted_pathname (name, FALSE); } }
void ldfile_add_library_path (const char *name, bfd_boolean cmdline) { search_dirs_type *new_dirs; if (!cmdline && config.only_cmd_line_lib_dirs) return; new_dirs = (search_dirs_type *) xmalloc (sizeof (search_dirs_type)); new_dirs->next = NULL; new_dirs->cmdline = cmdline; *search_tail_ptr = new_dirs; search_tail_ptr = &new_dirs->next; /* If a directory is marked as honoring sysroot, prepend the sysroot path now. */ if (name[0] == '=') { new_dirs->name = concat (ld_sysroot, name + 1, (const char *) NULL); new_dirs->sysrooted = TRUE; } else { new_dirs->name = xstrdup (name); new_dirs->sysrooted = is_sysrooted_pathname (name, FALSE); #ifdef ENABLE_POISON_SYSTEM_DIRECTORIES if (command_line.poison_system_directories && ((!strncmp (name, "/lib", 4)) || (!strncmp (name, "/usr/lib", 8)) || (!strncmp (name, "/usr/local/lib", 14)) || (!strncmp (name, "/usr/X11R6/lib", 14)))) { if (command_line.error_poison_system_directories) einfo (_("%X%P: error: library search path \"%s\" is unsafe for " "cross-compilation\n"), name); else einfo (_("%P: warning: library search path \"%s\" is unsafe for " "cross-compilation\n"), name); } #endif } }
static FILE * try_open (const char *name, bfd_boolean *sysrooted) { FILE *result; result = fopen (name, "r"); if (result != NULL) *sysrooted = is_sysrooted_pathname (name); if (verbose) { if (result == NULL) info_msg (_("cannot find script file %s\n"), name); else info_msg (_("opened script file %s\n"), name); } return result; }
bfd_boolean ldfile_open_file_search (const char *arch, lang_input_statement_type *entry, const char *lib, const char *suffix) { search_dirs_type *search; /* If this is not an archive, try to open it in the current directory first. */ if (! entry->maybe_archive) { if (entry->sysrooted && IS_ABSOLUTE_PATH (entry->filename)) { char *name = concat (ld_sysroot, entry->filename, (const char *) NULL); if (ldfile_try_open_bfd (name, entry)) { entry->filename = name; return TRUE; } free (name); } else if (ldfile_try_open_bfd (entry->filename, entry)) { entry->sysrooted = IS_ABSOLUTE_PATH (entry->filename) && is_sysrooted_pathname (entry->filename, TRUE); return TRUE; } if (IS_ABSOLUTE_PATH (entry->filename)) return FALSE; } for (search = search_head; search != NULL; search = search->next) { char *string; if (entry->dynamic && ! link_info.relocatable) { if (ldemul_open_dynamic_archive (arch, search, entry)) { entry->sysrooted = search->sysrooted; return TRUE; } } if (entry->maybe_archive) string = concat (search->name, slash, lib, entry->filename, arch, suffix, (const char *) NULL); else string = concat (search->name, slash, entry->filename, (const char *) 0); if (ldfile_try_open_bfd (string, entry)) { entry->filename = string; entry->sysrooted = search->sysrooted; return TRUE; } free (string); } return FALSE; }