Moshtaghi, Alireza via llvm-dev
2021-Apr-28 18:01 UTC
[llvm-dev] lld suspect behavior .group/rela/text input sections
Hi Can you help me to understand if I’m doing anything wrong or the problem is with lld? I need to use linker-script (below link) for linking freebsd kernel modules and pass -r to ld.lld (version 10) to make these modules relocatable. Some of the modules that I build are very big and also have .group sections on rela.text.<mangledname> and .text.<mangledname> Per ELF specification these sections should be treated as one and either all merged or none. But I think lld is not respecting that spec and merges all .text.<mangledname> sections while leaving the .group and .rela.text.<mangledname> sections in the output, which results in broken elf (when I try to load it into gdb, I get Bad Value error) Alternatively, when I link with ld.bfd, the .text.<manglenames> remain in the output and I’m able to load the object into gdb without error. Linker-script: https://github.com/freebsd/freebsd-src/blob/098dbd7ff7f3da9dda03802cdb2d8755f816eada/sys/conf/ldscript.amd64 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210428/e305f092/attachment-0001.html>
Fāng-ruì Sòng via llvm-dev
2021-Apr-28 22:10 UTC
[llvm-dev] lld suspect behavior .group/rela/text input sections
On Wed, Apr 28, 2021 at 11:02 AM Moshtaghi, Alireza via llvm-dev <llvm-dev at lists.llvm.org> wrote:> > Hi > > Can you help me to understand if I’m doing anything wrong or the problem is with lld? > > I need to use linker-script (below link) for linking freebsd kernel modules and pass -r to ld.lld (version 10) to make these modules relocatable. > > > > Some of the modules that I build are very big and also have .group sections on rela.text.<mangledname> and .text.<mangledname> > > > > Per ELF specification these sections should be treated as one and either all merged or none. But I think lld is not respecting that spec and merges all .text.<mangledname> sections while leaving the .group and .rela.text.<mangledname> sections in the output, which results in broken elf (when I try to load it into gdb, I get Bad Value error) > > > > Alternatively, when I link with ld.bfd, the .text.<manglenames> remain in the output and I’m able to load the object into gdb without error.Hi, do you have a minimal reproducible example (https://stackoverflow.com/help/minimal-reproducible-example)? Freebsd is not build-friendly when the user is not using FreeBSD ;-)> > > Linker-script: > > https://github.com/freebsd/freebsd-src/blob/098dbd7ff7f3da9dda03802cdb2d8755f816eada/sys/conf/ldscript.amd64