LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 33423 - lld fails to link kernel modules on FreeBSD/arm: can't create dynamic relocation R_ARM_ABS32 against local symbol in readonly segment
Summary: lld fails to link kernel modules on FreeBSD/arm: can't create dynamic relocat...
Status: RESOLVED INVALID
Alias: None
Product: lld
Classification: Unclassified
Component: ELF (show other bugs)
Version: unspecified
Hardware: PC FreeBSD
: P enhancement
Assignee: Rafael Ávila de Espíndola
URL:
Keywords:
Depends on:
Blocks: 23214
  Show dependency tree
 
Reported: 2017-06-12 11:14 PDT by emaste
Modified: 2017-06-21 11:01 PDT (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments
reproducer .tar (9.17 KB, application/x-xz)
2017-06-16 09:23 PDT, emaste
Details

Note You need to log in before you can comment on or make changes to this bug.
Description emaste 2017-06-12 11:14:00 PDT
Bug created for tracking - reproduction tarball will be added.

While linking the FreeBSD/arm kernel modules the linking fails with errors of the form:


ld -m armelf_fbsd -Bshareable -d -warn-common -o accf_data.ko.full  accf_data.kld
ld: error: can't create dynamic relocation R_ARM_ABS32 against local symbol in readonly segment
>>> defined in accf_data.kld
>>> referenced by accf_data.kld:(__set_modmetadata_set_sym__mod_metadata_md_accf_data_on_kernel)

ld: error: can't create dynamic relocation R_ARM_ABS32 against local symbol in readonly segment
>>> defined in accf_data.kld
>>> referenced by accf_data.kld:(__set_modmetadata_set_sym__mod_metadata_md_accf_data)

ld: error: can't create dynamic relocation R_ARM_ABS32 against local symbol in readonly segment
>>> defined in accf_data.kld
>>> referenced by accf_data.kld:(__set_sysinit_set_sym_accf_datamodule_sys_init)*** [accf_data.ko.full] Error code 1
Comment 1 Rafael Ávila de Espíndola 2017-06-15 16:38:58 PDT
ping on the reproduction tarball :-)
Comment 2 Rafael Ávila de Espíndola 2017-06-15 18:03:14 PDT
I noticed something similar in another build. Taking a look.
Comment 3 emaste 2017-06-16 09:23:47 PDT
Created attachment 18651 [details]
reproducer .tar
Comment 4 Rafael Ávila de Espíndola 2017-06-16 15:46:34 PDT
(In reply to Rafael Ávila de Espíndola from comment #2)
> I noticed something similar in another build. Taking a look.

At least in the case I hit it was just "-z text" being the default. Can you try passing "-z notext"?
Comment 5 emaste 2017-06-17 10:34:43 PDT
(In reply to Rafael Ávila de Espíndola from comment #4)
> 
> At least in the case I hit it was just "-z text" being the default. Can you
> try passing "-z notext"?

Indeed, I am able to link the arm kernel modules with -z notext, and for kernel modules applying .text relocations is not unreasonable.
Comment 6 Rafael Ávila de Espíndola 2017-06-19 07:47:10 PDT
(In reply to emaste from comment #5)
> (In reply to Rafael Ávila de Espíndola from comment #4)
> > 
> > At least in the case I hit it was just "-z text" being the default. Can you
> > try passing "-z notext"?
> 
> Indeed, I am able to link the arm kernel modules with -z notext, and for
> kernel modules applying .text relocations is not unreasonable.

Yes, a -z text .so is probably the most convenient format for a loadable module that is never shared.
Comment 7 emaste 2017-06-20 18:02:24 PDT
For reference, addressed in FreeBSD here: https://svnweb.freebsd.org/changeset/base/320179
Comment 8 emaste 2017-06-21 11:01:24 PDT
I've now run basic sanity tests with an LLD-linked FreeBSD kernel and modules on BeagleBone black and everything seems fine.

root@beaglebone:~ # readelf --string-dump=.comment `sysctl -n kern.bootfile` | grep -i link
  [    8a]  Linker: LLD 5.0.0 (FreeBSD 305145)