This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Report unimplemented -z options.
AbandonedPublic

Authored by grimar on Jun 21 2018, 7:57 AM.

Details

Summary

This is https://bugs.llvm.org/show_bug.cgi?id=37881,

it is about that LLD currently does not report any invalid/unsupported -z options.

There are few possible ways how this can be supported. A whitelist would be straightforward
but it does not look nice to list all of these options again since such list would be large.
The idea of this patch is to claim the options we check in the driver and hence mark them as used.
All unclaimed options than can be treated as unsupported and we can report them.

Diff Detail

Event Timeline

grimar created this revision.Jun 21 2018, 7:57 AM
chh added a subscriber: chh.Jun 21 2018, 9:38 AM
ruiu added a comment.Jun 26 2018, 10:51 PM

I wonder if this is the best way to do an error check. Did you try something like this?

for (auto *Arg : Args.filtered(OPT_z)) {
  StringRef S = Arg->getValue();
  if (S != "mudefs" && S != "hazardplt" && S != "relro" && ...)
    error("unknown -z value:  " + S);
}

This is simple-minded and less-abstracted, which is usually preferred in lld.

ELF/Driver.cpp
310

I'd make this function to take just one Key instead of arbitrary number of keys. I'd also rename this just claim.

dim added a subscriber: dim.Aug 4 2018, 9:47 AM

Ah, only now I've noticed that in the FreeBSD kernel link, we've been using the unsupported -z common-page-size= option:

--- kernel.full ---
linking kernel.full
ld: error: unknown -z value: common-page-size=4096
*** [kernel.full] Error code 1

This flag was added for ifunc support, but I'm not 100% sure if it is needed at all. Does lld always assume a common page size of 4096 (or whatever the OS reports as PAGESIZE)?

grimar added a comment.EditedAug 4 2018, 10:31 PM
In D48433#1188567, @dim wrote:

Ah, only now I've noticed that in the FreeBSD kernel link, we've been using the unsupported -z common-page-size= option:

--- kernel.full ---
linking kernel.full
ld: error: unknown -z value: common-page-size=4096
*** [kernel.full] Error code 1

This flag was added for ifunc support, but I'm not 100% sure if it is needed at all. Does lld always assume a common page size of 4096 (or whatever the OS reports as PAGESIZE)?

I believe, it is always a 4096:
https://github.com/llvm-mirror/lld/blob/master/ELF/Target.h#L80
Except for sparc:
https://github.com/llvm-mirror/lld/blob/master/ELF/Arch/SPARCV9.cpp#L44

ruiu added a comment.Aug 6 2018, 9:06 AM

This flag was added for ifunc support, but I'm not 100% sure if it is needed at all. Does lld always assume a common page size of 4096 (or whatever the OS reports as PAGESIZE)?

We generally don't depend on any value that the host OS reports to make lld work exactly the same way on any platform when the same set of files and command line options are given, which should help cross linking.