lld: add -z interpose support
ClosedPublic

Authored by emaste on Sep 14 2018, 7:04 AM.

Details

Summary

-z interpose sets the DF_1_INTERPOSE flag, marking the object as an interposer.

FreeBSD PR 230604

Diff Detail

Repository
rL LLVM
emaste created this revision.Sep 14 2018, 7:04 AM
emaste added a subscriber: dim.Sep 14 2018, 7:06 AM

See also https://reviews.freebsd.org/D17172 for a lld 6 version intended for commit to FreeBSD's in-tree lld.

test/ELF/dt_flags.s
10–13 ↗(On Diff #165498)

I think it makes sense to validate flags individually to ensure we don't mix up bits or accidentally set flags we shouldn't, but I will just add it to the list in FLAGS: above if that's desired.

grimar added inline comments.Sep 14 2018, 7:09 AM
test/ELF/dt_flags.s
10–13 ↗(On Diff #165498)

I would be consistent with the existent test and reuse FLAGS

11 ↗(On Diff #165498)

This could be a single line:

ld.lld -z interpose -Bsymbolic %t %t.so -o %t1

emaste added inline comments.Sep 14 2018, 7:21 AM
test/ELF/dt_flags.s
10–13 ↗(On Diff #165498)

I can make that change, although the test coverage is not as good; I made this part of the change first:

 # RUN: ld.lld -z global -z initfirst -z now -z nodelete -z nodlopen -z origin \
-# RUN:   -Bsymbolic %t %t.so -o %t1
+# RUN:   -z interpose -Bsymbolic %t %t.so -o %t1
 # RUN: llvm-readobj -dynamic-table %t1 | FileCheck -check-prefix=FLAGS %s

and the test still passed, because the new INTERPOSE flag is at the end and FLAGS: 0x000000006FFFFFFB FLAGS_1 NOW GLOBAL NODELETE INITFIRST NOOPEN ORIGIN still matches.

emaste updated this revision to Diff 165503.Sep 14 2018, 7:22 AM

Reuse existing FLAGS: test

grimar accepted this revision.Sep 14 2018, 7:23 AM

LGTM.

This revision is now accepted and ready to land.Sep 14 2018, 7:23 AM
emaste updated this revision to Diff 165504.Sep 14 2018, 7:24 AM

keep flags in order

Still LGTM :)

Closed by commit rL342239: lld: add -z interpose support (authored by emaste, committed by ). · Explain WhySep 14 2018, 7:29 AM
This revision was automatically updated to reflect the committed changes.