dtolnay / dtolnay/linkme

Undefined symbols __start_linkm2_*, __start_linkme_*, __stop_linkm2_*, __stop_linkme_*

Open
#111 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
890
Forks
46
PR merge metrics
No merged PRs in 30d

Description

The following symbols are not defined:
`__start_linkm2_*`, `__start_linkme_*`, `__stop_linkm2_*`, `__stop_linkme_*`

The build is a static archive for a freestanding custom target with rust-lld with rust 1.85.0. The issue seems identical to the one reported at https://github.com/dtolnay/linkme/pull/88 .
I'm not sure if the issue is supposed to be fixed or not, but none of the workarounds seems to work:
* `-Clink-arg=-Wl,-z,nostart-stop-gc`
* `-Clink-dead-code` is broken for my setup (`-Zbuild-std`) so I cannot test it
* used_linker feature

The resulting .a file contains:

* `linkme_*` and `linkm2_*` sections:
```
[12] linkme_FEATURES PROGBITS 0000000000000000 00dd28 000000 00 WA 0 0 1
[13] linkm2_FEATURES PROGBITS 0000000000000000 00dd28 000008 00 A 0 0 8
[130] linkme_FEATURES PROGBITS 0000000000000000 016881 000002 00 A 0 0 1
```

* a global undefined symbol for each of `__start_linkm2_*`, `__start_linkme_*`, `__stop_linkm2_*`, `__stop_linkme_*`:
```
565: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND __stop_linkm2_FEATURES
566: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND __start_linkm2_FEATURES
567: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND __start_linkme_FEATURES
568: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND __stop_linkme_FEATURES
```
* and relocations mentioning them:
```
0000000000007804 0000023700000113 R_AARCH64_ADR_PREL_PG_HI21 0000000000000000 __start_linkme_FEATURES + 0
```

But no definition anywhere.

Using rust-lld is important here so I don't depend on the platform linker, as this build is done dynamically along some C code, with a wide range of C toolchains. Relying on the user-provided linker would be a recipe for build failure in exotic configurations. OTH rust-lld provides me with the same linker everywhere for the Rust part of the code. If rust-lld is not supported at the moment, it may be a good idea to mention it in the documentation.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the static-archive build for a freestanding custom target with Rust 1.85.0 and rust-lld, then inspect the archive's linkme/linkm2 sections, undefined symbols, and relocations. Compare the behavior with the workaround described in dtolnay/linkme#88; done means the symbols are resolved, or the documentation clearly states rust-lld is unsupported and identifies any valid workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.