[PATCH 1/6] ld: don't generate base relocations in PE output for absolute symbols

Alan Modra amodra@gmail.com
Thu Mar 4 04:46:59 GMT 2021


On Tue, Mar 02, 2021 at 10:47:03AM +0100, Jan Beulich via Binutils wrote:
> It is the very nature of absolute symbols that they don't change even
> if the loader decides to put the image at other than its link-time base
> address. Of the linker-defined (and PE-specific) symbols __image_base__
> (and its alias) needs special casing, as it'll still appear to be
> absolute at this point.
> 
> A new inquiry function in ldexp.c is needed because PE base relocations
> get generated before ldexp_finalize_syms() runs, yet whether a
> relocation is needed depends on the ultimate property of a symbol.
> 
> ld/
> 2021-02-XX  Jan Beulich  <jbeulich@suse.com>
> 
> 	* ldexp.c (ldexp_is_final_sym_absolute): New.
> 	* ldexp.h (ldexp_is_final_sym_absolute): Declare.
> 	* pe-dll.c (generate_reloc): Skip absolute symbols.

OK.

> +		  /* Nor for absolute symbols.  */
> +		  else if (blhe && ldexp_is_final_sym_absolute (blhe)
> +			   && (!blhe->linker_def
> +			       || (strcmp(sym->name, "__image_base__")
> +				   && strcmp(sym->name, U ("__ImageBase")))))

Space after strcmp.

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list