[patch] Fix PR ld/24574

Eric Botcazou ebotcazou@adacore.com
Fri Sep 6 07:24:00 GMT 2019


> "may trash memory" is alarmist.  Replacing a pointer to a string
> (typically in memory containing a copy of .strtab or .dynstr) with a
> pointer to another string won't "trash memory".

Yes, that's probably the reason why I initially removed the line.  I guess 
that ideally we would need to make this previously undefined symbol hidden
or anonymous if this is possible.  For the time being the code reads:

	    /* Let's differentiate it somehow from defined.  */
	    undef->type = bfd_link_hash_defweak;
	    undef->u.def.value = sym->u.def.value;
	    undef->u.def.section = sym->u.def.section;

	    /* We replace the original name with the __imp_ prefixed one, this
	       1) may trash memory 2) leads to duplicate symbols.  But this is
	       better than having a misleading name that can confuse GDB.  */
	    undef->root.string = sym->root.string;

-- 
Eric Botcazou



More information about the Binutils mailing list