This is not exactly the same format as bfd ld, but should serve a similar purpose.
Diff Detail
Event Timeline
Is there any reason we can't print out in the exact same format as ld.bfd? Because LLD is basically a drop-in replacement, compatible output would be generally appreciated.
lld/ELF/MapFile.cpp | ||
---|---|---|
7 | This needs a file comment. At least it should mention that this is for -Map and what kind of information is printed, at the granularity of the ld man page. | |
24–27 | nit: maybe this style is more common? OS << ... << ...; as opposed to OS << ...; OS << ...; | |
99 | Do you need this temporary variable? | |
105–112 | This seems like a pretty common pattern. We probably should have a class that does this (open with a temporary file name and rename on close) automatically. | |
lld/ELF/MapFile.h | ||
1 | Not directly related to this patch, but we have many instances of this kind of "effectively one line" .h files in LLD. In some case, some declarations are piggy backed to a somewhat unrelated header (e.g. markLive's declaration is in Writer.h.) I once wondered if we should create a header for miscellaneous functions, say, LLD.h, to aggregate them. What do you think? |
Take this with a grain of salt, Rui, but last I checked --map as emitted by bfd wasn't particularly informative.
I also personally don't think we should really stick with compatibility for debugging options, assuming we can provide a better output.
I have to say that I prefer this style of output to what I implemented for /lldmap in the COFF linker. At some point we should make the COFF linker use this format or something similar.
I wonder whether it would be worth making absolute symbols show up in the map file.
lld/test/ELF/map-file.s | ||
---|---|---|
33 | You probably want to use regexes to match the paths here and below. |
LGTM with these changes as everybody seems happy with this output format.
lld/ELF/Driver.cpp | ||
---|---|---|
515 | Move the definitions of -Map and -Map= in Options.td so that they are not under the comment saying that they are for compatibility and silently ignored. | |
lld/ELF/MapFile.cpp | ||
39 | For 64-bit output, you want to write Address in 64 bit. | |
40 | This and in other write* functions probably should print out a trailing "\n" so that you don't need to do that in writeMapFile2. |
Why do you want this feature by the way? I wonder if you have a plan to use that soon.
I wonder if printing out meta info (such as all command line options, time stamp, etc.) as a header of a map file is useful. What do you think?
Move the definitions of -Map and -Map= in Options.td so that they are not under the comment saying that they are for compatibility and silently ignored.