[PATCH v2] elf: Only use function size from regular object

Alan Modra amodra@gmail.com
Fri Sep 11 02:52:13 GMT 2026


On Fri, Sep 11, 2026 at 07:32:28AM +0800, H.J. Lu wrote:
> +		  /* Only use function size defined in regular object
> +		     since function size defined in shared library at
> +		     link-time is irrelevant.  */

I'm not completely convinced this is true.  If you had run the
testsuite over a good set of targets, you would have discovered:
mipsisa32r2el-elf  +FAIL: Build pr34585b.so
mipsisa32r2el-elf  +FAIL: Build pr34585c.so
mipsisa32r2el-elf  +FAIL: Build pr34585d.so
mipsisa32r2el-elf  +FAIL: Build pr34585e.so
mips-sgi-irix6  +FAIL: Build pr34585b.so
mips-sgi-irix6  +FAIL: Build pr34585c.so
mips-sgi-irix6  +FAIL: Build pr34585d.so
mips-sgi-irix6  +FAIL: Build pr34585e.so
mipstx39-elf  +FAIL: Build pr34585b.so
mipstx39-elf  +FAIL: Build pr34585c.so
mipstx39-elf  +FAIL: Build pr34585d.so
mipstx39-elf  +FAIL: Build pr34585e.so
powerpc64-freebsd  +FAIL: ld-powerpc/ambiguousv1b
powerpc64le-linux-gnu  +FAIL: ld-powerpc/ambiguousv1b
powerpc64-linux-gnu  +FAIL: ld-powerpc/ambiguousv1b
powerpc-eabisim  +FAIL: ld-powerpc/ambiguousv1b
powerpc-eabivle  +FAIL: ld-powerpc/ambiguousv1b
powerpcle-elf  +FAIL: ld-powerpc/ambiguousv1b
powerpc-linux-gnu  +FAIL: ld-powerpc/ambiguousv1b

The mips fails are all due to PRC[0xff01] appearing rather than a
normal section index, so easily fixed with changes to the testsuite
regex.

The powerpc fails are due to ELFv1 function symbols being defined on a
descriptor.  Despite having STT_FUNC type they are really a data
object, and prior to around 2004 when gcc emitted code with
dot-symbols for the function code entry point their size was that of
the descriptor.  That made lots of weird stuff possible, for example
copy relocs on STT_FUNC, because the copy was of the descriptor not
the function code.  Without the symbol size being updated that is no
longer possible.  I doubt anyone cares, but something should be
updated in elf64-ppc.c adjust_dynamic_symbol to suit your change, or
STT_FUNC size from these descriptors should continue to be copied out
of shared libraries.  Possibly the correct course of action is to
delete everything to do with dot-symbols, but I'm of course not asking
you to do that.

-- 
Alan Modra


More information about the Binutils mailing list