llvm/llvm-project

Finish / clean up MapFile implementation

Open

#50.033 geöffnet am 12. Juni 2021

Auf GitHub ansehen
 (12 Kommentare) (0 Reaktionen) (1 zugewiesene Person)C++ (10.782 Forks)batch import
bugzillagood first issuelldlld:MachO

Repository-Metriken

Stars
 (26.378 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 2h) (1.000 gemergte PRs in 30 T)

Beschreibung

Bugzilla Link 50689
Version unspecified
OS All
CC @gkmhub,@int3,@thevinster,@nico,@carbon-steel,@smeenai,@TH3CHARLie

Extended Description

These are probably good tasks for someone looking to get familiarized with the LLD codebase, since the mapfile isn't critical to what we are working on at the moment. (Please ping me first before starting on these.)

  1. Dump dead-stripped symbols, as per this TODO: https://github.com/llvm/llvm-project/blob/main/lld/MachO/MapFile.cpp#L153. Essentially, symbols for which isLive() returns false.

  2. getSectionSyms() puts all the symbols into a map of section -> symbols, but this seems unnecessary. This was likely copied from the ELF port, which prints a section header before the list of symbols it contains. But the Mach-O map file doesn't print these headers.

  3. Parallelize the symbol sort. We can use LLVM's parallel_sort for this. If two symbols have the same address, we can use their symbol name to tie-break; the end result should be deterministic.

  4. Dump the cstring / fixed-width literals (from CStringInputSection and WordLiteralInputSection respectively) into the map file.

To see the expected map file output, download the tar attachment from llvm/llvm-project#48001 . Unpack and link it like so: ld -map mapfile @​response.txt. This will generate a "mapfile" file in the CWD. This mapfile will contain examples dead symbols and literals (grep for "literal string" in the file).

That said, this file is pretty large (since Chromium is pretty large), so you may want to construct smaller test programs for a better understanding.

Contributor Guide