[PATCH] ld - Add SYMBOL_ABI_ALIGNMENT variable and apply to __bss_start

Andreas Krebbel krebbel@linux.ibm.com
Wed Jun 28 06:23:52 GMT 2023


On 6/27/23 16:14, Nick Clifton wrote:
> Hi Andreas,
> 
>> Currently not specific alignment is applied to the __bss_start
>> symbol. However, on s390x we require every symbol to be on an even
>> address.  The patch introduces a new variable for the elf.sc template
>> which allows to specify such an symbol alignment requirement.
> 
> This patch looks good, but I see one issue - there are lot more symbols
> provided by the elf.sc template than just __bss_start.  So if an ABI
> requires symbols to be aligned, then that should apply to all symbols,
> right ?

I think most of the other symbols are implicitly aligned because of other effects. The same way it
used to be for __bss_start actually. GCC for Z pads the .data section size to a multiple of 8 but
LLVM doesn't. But you are right. In order to make it more robust we should apply it to the other
symbols as well. I'll have a look.

> Actually there is one other thing.  Rather than doing:
> 
>     ${RELOCATING+. = ALIGN(${SYMBOL_ABI_ALIGNMENT});}
>     ${RELOCATING+${CREATE_SHLIB+PROVIDE (}${USER_LABEL_PREFIX}__bss_start = .${CREATE_SHLIB+)};}
> 
> Wouldn't it make more sense to do:
> 
>     ${RELOCATING+${CREATE_SHLIB+PROVIDE (}${USER_LABEL_PREFIX}__bss_start = ALIGN (.${CREATE_SHLIB+), ${SYMBOL_ABI_ALIGNMENT});}

Yes, that's better.

> Ie making it clear that the alignment is being applied to the symbol.
> 
> It might even be possible to create a macro to do all of this
> USER_LABEL_PREFIX and ALIGN munging, so that it does not have
> to be repeated countless times in the elf.sc file.  I have not
> actually checked to see if this is possible, but it would be
> nice if it could be done.

Agreed. I'm not that familiar with what is possible in these files but I'll try to come up with
something.

Thanks for having a look!

Bye,

Andreas

> 
> Cheers
>    Nick
> 



More information about the Binutils mailing list