This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Implement --push-state/--pop-state.
AbandonedPublic

Authored by grimar on Sep 12 2017, 2:24 AM.

Details

Reviewers
ruiu
rafael
Summary

This is PR34567 ("Bug 34567 - lld: unknown argument: --push-state, --pop-state on ubuntu when using asan")

Documentation (https://sourceware.org/binutils/docs/ld/Options.html) specifies these options as:

--push-state
The --push-state allows to preserve the current state of the flags which govern the input file handling so that they can all be restored with one corresponding --pop-state option.
The option which are covered are: -Bdynamic, -Bstatic, -dn, -dy, -call_shared, -non_shared, -static, -N, -n, --whole-archive, --no-whole-archive, -r, -Ur, --copy-dt-needed-entries, --no-copy-dt-needed-entries, --as-needed, --no-as-needed, and -a.
--pop-state
Undoes the effect of –push-state, restores the previous values of the flags governing input file handling.

gold implementation was: https://sourceware.org/bugzilla/show_bug.cgi?id=18989.

Unlike said in specification, gold preserves only position-dependent options. And that behavior looks correct for me,
I do not see any reasons to preserve/restore position-independent options. Also gold implements real stack with nesting to any depth.
I do not think we really need to do that, at least until bfd does not supports the same.
This patch implements probably simplest way I can imagine.

Diff Detail

Event Timeline

grimar created this revision.Sep 12 2017, 2:24 AM
ruiu edited edge metadata.Sep 12 2017, 10:13 AM

I think I don't really like this option. This seems too hairy feature to me. I believe it shouldn't have been added to the linker in the first place.

In D37733#868245, @ruiu wrote:

I think I don't really like this option. This seems too hairy feature to me. I believe it shouldn't have been added to the linker in the first place.

Its wierd feature indeed. It was reported (https://stackoverflow.com/questions/37603238/fsanitize-not-using-gold-linker-in-gcc-6-1) that -fuse-ld=gold
could be a workaround previously for use of gcc -fsanitize. But now gold also supports it and I wonder what would be the correct behavior for LLD.
If we don't support it them most likely will fail, though feature itself and its description looks not worked out well for me.
I think we can put this on hold for now and watch.

grimar retitled this revision from [ELF} - Implement --push-state/--pop-state. to [ELF] - Implement --push-state/--pop-state..Sep 13 2017, 1:21 AM

Well making a link to lld as ld.gold doesn't work as a workaround anyway. Looks like the only "workaround" is to use clang instead of gcc since these options are added by gcc on ubuntu for some obscure reason.

grimar abandoned this revision.Oct 10 2017, 1:12 AM

Abandoning until will be decided LLD wants to support it.