[PATCH] D63190: Add -gnu-map option to emit a map file in the GNU-tsyle format.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 23:59:12 PDT 2019


MaskRay added inline comments.


================
Comment at: lld/ELF/MapFile.cpp:245
+  OS << "Memory map\n";
+
+  for (BaseCommand *Base : Script->SectionCommands) {
----------------
gold reports ` ** file header` and ` ** segment headers`.


================
Comment at: lld/ELF/MapFile.cpp:257
+
+    OS << format(" 0x%016llx", OSec->Addr) << " "
+       << left_justify(("0x" + Twine::utohexstr(OSec->Size)).str(), 11) << "\n";
----------------
peter.smith wrote:
> gold right justifies the size, but I doubt that is significant.
gold essentially uses `0x%08llx` for 32-bit targets.

(the actual code is `fprintf(this->map_file_, "0x%0*llx %10s", parameters->target().get_size() / 4, static_cast<unsigned long long>(os->address()), sizebuf);`)



================
Comment at: lld/ELF/MapFile.cpp:259
+       << left_justify(("0x" + Twine::utohexstr(OSec->Size)).str(), 11) << "\n";
+
+    // Dump symbols for each input section.
----------------
peter.smith wrote:
> gold will print out the LMA if it is different at this point. Followed by (before compression) if the output section has been subject to debug compression.
LMA is printed if either `AT(LMA)` or `AT>LMA_REGION` is specified.

This can be tested with `if (OSec->LMAExpr || OSec->LMARegion)` but we don't seem to store the LMA address as gold does. So I don't know how we can dump this piece of information.


================
Comment at: lld/ELF/MapFile.cpp:268
+        if (IS->Name.size() <= 14)
+          OS << " " << left_justify(IS->Name, 14);
+        else
----------------
peter.smith wrote:
> Gold has some custom name printing for its linker generated content (do_print_to_mapfile) . For example the .plt comes out as 
> 
> ```
> **PLT 
> ```
> .rela.dyn comes out as
> 
> ```
> ** dynamic relocs
> ``` 
> 
`** gdb_index`
`** GOT PLT`
`** PLT`
`** .LA25.stubs`
`** section headers`
`** .reginfo`
`** string table`
`** relocs` for static relocation sections.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63190/new/

https://reviews.llvm.org/D63190





More information about the llvm-commits mailing list