llvm/llvm-project

Finish / clean up MapFile implementation

Open

#50.033 aberto em 12 de jun. de 2021

Ver no GitHub
 (12 comments) (0 reactions) (1 assignee)C++ (10.782 forks)batch import
bugzillagood first issuelldlld:MachO

Métricas do repositório

Stars
 (26.378 stars)
Métricas de merge de PR
 (Mesclagem média 1d 2h) (1.000 fundiu PRs em 30d)

Description

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.

Guia do colaborador