aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPter Chubb <peter.chubb@unsw.edu.au>2023-07-18 17:06:14 +0100
committerNick Clifton <nickc@redhat.com>2023-07-18 17:06:14 +0100
commit5d17455d0d627c04af6ca66b3dfdca9fd3276fb3 (patch)
treeeee09ec19078deb9f303c719f1a1ae1455f3dd7c
parentfd7cc3faa26c8c8ae1901e79c1dad28d7b5e9616 (diff)
downloadgdb-5d17455d0d627c04af6ca66b3dfdca9fd3276fb3.zip
gdb-5d17455d0d627c04af6ca66b3dfdca9fd3276fb3.tar.gz
gdb-5d17455d0d627c04af6ca66b3dfdca9fd3276fb3.tar.bz2
PR 30632 - ld segfaults if linker script includes a STARTUP line.
-rw-r--r--ld/ldlang.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c
index b3a89bf..a357f80 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -1136,9 +1136,15 @@ new_afile (const char *name,
lang_has_input_file = true;
- name = ldfile_possibly_remap_input (name);
- if (name == NULL)
- return NULL;
+ /* PR 30632: It is OK for name to be NULL. For example
+ see the initialization of first_file in lang_init(). */
+ if (name != NULL)
+ {
+ name = ldfile_possibly_remap_input (name);
+ /* But if a name is remapped to NULL, it should be ignored. */
+ if (name == NULL)
+ return NULL;
+ }
p = new_stat (lang_input_statement, stat_ptr);
memset (&p->the_bfd, 0,