i386: Avoid rely on linker optimization to avoid relocation
commit59aa41585f668b70b86a8e2617057da08f3291cc
authorAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Thu, 17 Nov 2022 18:13:08 +0000 (17 15:13 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 21 Nov 2022 14:25:35 +0000 (21 11:25 -0300)
tree5b13f629a5e2cd85ebbd5e8250cc63a030d3db5d
parenteb4181e9f4a512de37dad4ba623c921671584dea
i386: Avoid rely on linker optimization to avoid relocation

lld does not implement all the linker optimization to avoid the GOT
relocation as done by binutils (bfd/elf32-i386.c:elf_i386_convert_load_reloc).
The current 'movl main@GOT(%ebx), %eax' will then create a GOT
relocation when building with lld, which make static-pie status to
not being able to start the provided main function.

The change uses a __wrap_main local symbol, which in turn calls main
(similar as used by aarch64 and s390x).

Checked on i686-linux-gnu with binutils and lld.
Reviewed-by: Fangrui Song <maskray@google.com>
sysdeps/i386/start.S