Page MenuHomeFreeBSD

rtld: fix reference tracking with common symbols
Needs ReviewPublic

Authored by vangyzen on Sep 7 2022, 9:29 PM.

Details

Reviewers
markj
kib
Summary

See dlopen_common_global.md for a detailed description of the bug.

The proposed fix is an ugly hack, due in part to casting away const (and the #pragma that requires). I would be delighted to throw it away and implement your better idea. Removing const from SymLook::defobj_out is fairly invasive and feels wrong.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 47285
Build 44172: arc lint + arc unit

Event Timeline

I do not think that workarounds for application bugs should be performed in ld-elf.so.1.

I do not completely understand the problem, but did you tried to change libcompiler_rt (is it libgcc.s.so BTW?) to be linked with -Bsymbolic? This might be the right thing to do regardless of the specific bug we are discussing.

I think the real fix, following the ELF model of the COPY relocation, is to have the main binary linked against libgcc_s.so, and more, main binary needs to reference symbols needed by dlopened dsos.
This is how ELF is supposed to work.

Or do dlclose nss/pam modules, or mark then unloadable for your instrumented build.

rtld never converts symbols references into refcounts, and I do not see why it is reasonable to do to workaround some application bug.