https://sourceware.org/bugzilla/show_bug.cgi?id=30632
Bug ID: 30632 Summary: ld segfaults if linker script includes Product: binutils Version: 2.42 (HEAD) Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: peter.chubb at unsw dot edu.au Target Milestone: --- ld -Tscript.ld segfaults in ldlang.c when a startup file is given in the script. The problem is commit fb221fba1a5eb05355f248d6aa1e3ab4316899fd which makes first_file NULL if NULL is My script.ld contains: ---- STARTUP(crt0.o); ---- backtrace: #0 lang_startup (name=0x5555556f50a0 "crt0.o") at ../../ld/ldlang.c:8704 #1 0x0000555555564e7a in yyparse () at ../../ld/ldgram.y:850 #2 0x0000555555569e88 in parse_args (argc=<optimized out>, argv=<optimized out>) at ../../ld/lexsup.c:1385 #3 0x00005555555634f5 in main (argc=<optimized out>, argv=<optimized out>) at ../../ld/ldmain.c:375 (gdb) print first_file $1 = (lang_input_statement_type *) 0x0 first_file is set in lang_init at line 1331 of ld/ldlang.c: first_file = lang_add_input_file (NULL, lang_input_file_is_marker_enum, NULL); lang_add_input_file() passes its first argument (here NULL) to new_afile() Commit fb221fba1a5eb05355f248d6aa1e3ab4316899fd changed new_afile() to return NULL if the name was NULL. (near line 1139 of ldlang.c): name = ldfile_possibly_remap_input (name); if (name == NULL) return NULL; I suggest the check for NULL here is incorrect, as NULL is an allowed value for the name. Commenting out the if statement and its return fixes the issue. -- You are receiving this mail because: You are on the CC list for the bug.