This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Treat --just-symbols file as an input.
AbandonedPublic

Authored by grimar on Mar 15 2018, 7:21 AM.

Details

Summary

This is PR36737.

Patch changes --just-symbols implementation so that we
count such files as inputs now.

Reimplementation also grants additional benefits. Now
--just-symbols file is added to Files and ObjectFiles just as
a regular input file.

With that, it not only allows our code to infer the ELF target automatically
(without additional changes) but also let the rest of LLD code to do its job too.
For example, I added test case showing we are able now to report symbols from
just symbols file with --cref.

Diff Detail

Event Timeline

grimar created this revision.Mar 15 2018, 7:21 AM
grimar updated this revision to Diff 138551.Mar 15 2018, 7:42 AM
  • Moved JustSymbols flag to ObjFile.
  • Cosmetic changes.
espindola accepted this revision.Mar 15 2018, 8:59 PM

LGTM

ELF/InputFiles.cpp
293

I think you can pass just "this" to CHECK instead of "toString(this)".

There are a few more cases in this function.

This revision is now accepted and ready to land.Mar 15 2018, 8:59 PM
ruiu added a comment.Mar 15 2018, 9:33 PM

I think I implemented the exact same thing in my patch already which I haven't submitted, and I think mine is better than this patch. I don't like to mix adding a feature for JustSymbols to ObjFile class. Because JustSymbols is so minor, I don't want to mix code for that feature with the regular code path.

ELF/Driver.cpp
176

You don't need to call this function to add a new file to Files. Let's keep it simple. Just call createObjectFile and directly add its return value to Files. Basically, you should avoid adding this kind of ad-hoc new parameter to an existing function.

ruiu added a comment.Mar 15 2018, 9:38 PM

I prefer https://reviews.llvm.org/D42025 over this patch in case we need this feature, though I'm not sure if we need it in the first place. I'm not against adding this, but I'd like to know what's a use case of this feature first.

I prefer https://reviews.llvm.org/D42025 over this patch in case we need this feature, though I'm not sure if we need it in the first place. I'm not against adding this, but I'd like to know what's a use case of this feature first.

During the initial implementation Chih-Mao Chen wrote:

                                                                                                                                                                                                                                                                                                 
It can be used to produce an object file containing the offset of symbols in vdso:                                                                                                                                                                                                               
https://github.com/riscv/riscv-linux/blob/ae64f9bd1d3621b5e60d7363bc20afb46aede215/arch/riscv/kernel/vdso/Makefile#L41

Which also points out that we should probably support .o and .so too (as we do now).

I prefer https://reviews.llvm.org/D42025 over this patch in case we need this feature, though I'm not sure if we need it in the first place. I'm not against adding this, but I'd like to know what's a use case of this feature first.

D42025 looks good for me too. Seems it should work with just-symbols-cref.s from this patch out of the box, I also suggest to include it.

grimar abandoned this revision.Mar 30 2018, 2:00 AM

D42025 was landed instead.