aboutsummaryrefslogtreecommitdiff
path: root/ld/ldfile.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2024-10-26 08:57:49 +1030
committerAlan Modra <amodra@gmail.com>2024-10-26 10:25:38 +1030
commit6ecc44f6980c0f8c0f0934bc10412c1d7fa3c544 (patch)
tree295df2ab4dbdc9efc584a5e87073bf754d85ff61 /ld/ldfile.c
parent3d17c8817216343179f64d1a682311a70774ccb4 (diff)
downloadgdb-6ecc44f6980c0f8c0f0934bc10412c1d7fa3c544.zip
gdb-6ecc44f6980c0f8c0f0934bc10412c1d7fa3c544.tar.gz
gdb-6ecc44f6980c0f8c0f0934bc10412c1d7fa3c544.tar.bz2
PR32300, --dependency-file: link dependencies are not all collected
PR 32300 PR 31904 Revert patch accidentally committed with 057a2b4c4b
Diffstat (limited to 'ld/ldfile.c')
-rw-r--r--ld/ldfile.c69
1 files changed, 19 insertions, 50 deletions
diff --git a/ld/ldfile.c b/ld/ldfile.c
index 87be885..f1107a1 100644
--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -40,6 +40,12 @@
#include "plugin.h"
#endif /* BFD_SUPPORTS_PLUGINS */
+bool ldfile_assumed_script = false;
+const char *ldfile_output_machine_name = "";
+unsigned long ldfile_output_machine;
+enum bfd_architecture ldfile_output_architecture;
+search_dirs_type *search_head;
+
#ifdef VMS
static char *slash = "";
#else
@@ -56,12 +62,6 @@ typedef struct search_arch
struct search_arch *next;
} search_arch_type;
-bool ldfile_assumed_script = false;
-const char * ldfile_output_machine_name = "";
-unsigned long ldfile_output_machine;
-enum bfd_architecture ldfile_output_architecture;
-search_dirs_type * search_head;
-
static search_dirs_type **search_tail_ptr = &search_head;
static search_arch_type *search_arch_head;
static search_arch_type **search_arch_tail_ptr = &search_arch_head;
@@ -303,20 +303,21 @@ is_sysrooted_pathname (const char *name)
}
/* Adds NAME to the library search path.
- Makes a copy of NAME using xmalloc().
- Returns a pointer to the newly created search_dirs_type structure
- or NULL if there was a problem. */
+ Makes a copy of NAME using xmalloc(). */
-search_dirs_type *
-ldfile_add_library_path (const char *name, enum search_dir_source source)
+void
+ldfile_add_library_path (const char *name, bool cmdline)
{
search_dirs_type *new_dirs;
- if (source != search_dir_cmd_line && config.only_cmd_line_lib_dirs)
- return NULL;
+ if (!cmdline && config.only_cmd_line_lib_dirs)
+ return;
new_dirs = (search_dirs_type *) xmalloc (sizeof (search_dirs_type));
- new_dirs->source = source;
+ 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. */
@@ -326,25 +327,6 @@ ldfile_add_library_path (const char *name, enum search_dir_source source)
new_dirs->name = concat (ld_sysroot, name + strlen ("$SYSROOT"), (const char *) NULL);
else
new_dirs->name = xstrdup (name);
-
- /* Accumulate script and command line sourced
- search paths at the end of the current list. */
-#if BFD_SUPPORTS_PLUGINS
- /* PR 31904: But put plugin sourced paths at the start of the list. */
- if (source == search_dir_plugin)
- {
- new_dirs->next = search_head;
- search_head = new_dirs;
- }
- else
-#endif
- {
- new_dirs->next = NULL;
- *search_tail_ptr = new_dirs;
- search_tail_ptr = &new_dirs->next;
- }
-
- return new_dirs;
}
/* Try to open a BFD for a lang_input_statement. */
@@ -370,9 +352,9 @@ ldfile_try_open_bfd (const char *attempt,
return false;
}
- /* PR 30568: Do not track plugin generated object files. */
+ /* PR 30568: Do not track lto generated temporary object files. */
#if BFD_SUPPORTS_PLUGINS
- if (entry->plugin != NULL)
+ if (!entry->flags.lto_output)
#endif
track_dependency_files (attempt);
@@ -383,7 +365,7 @@ ldfile_try_open_bfd (const char *attempt,
entry->the_bfd->is_linker_input = 1;
#if BFD_SUPPORTS_PLUGINS
- if (entry->plugin != NULL)
+ if (entry->flags.lto_output)
entry->the_bfd->lto_output = 1;
#endif
@@ -594,14 +576,6 @@ ldfile_open_file_search (const char *arch,
{
char *string;
-#if BFD_SUPPORTS_PLUGINS
- /* PR 31904: Only check a plugin sourced search
- directory if the file is from the same plugin. */
- if (search->source == search_dir_plugin
- && entry->plugin != search->plugin)
- continue;
-#endif
-
if (entry->flags.dynamic && !bfd_link_relocatable (&link_info))
{
if (ldemul_open_dynamic_archive (arch, search, entry))
@@ -870,7 +844,7 @@ ldfile_find_command_file (const char *name,
{
search_dirs_type **save_tail_ptr = search_tail_ptr;
search_tail_ptr = &script_search;
- (void) ldfile_add_library_path (script_dir, search_dir_cmd_line);
+ ldfile_add_library_path (script_dir, true);
search_tail_ptr = save_tail_ptr;
}
}
@@ -884,11 +858,6 @@ ldfile_find_command_file (const char *name,
search != NULL;
search = search->next)
{
-#if BFD_SUPPORTS_PLUGINS
- /* Do not search for linker commands in plugin sourced search directories. */
- if (search->source == search_dir_plugin)
- continue;
-#endif
path = concat (search->name, slash, name, (const char *) NULL);
result = try_open (path, sysrooted);
free (path);