This is an archive of the discontinued LLVM Phabricator instance.

Add a "--load-address <addr>" option to llvm-gsymutil.
Needs ReviewPublic

Authored by clayborg on Oct 14 2022, 12:56 PM.

Details

Summary

This option allows clients to set the load address for a GSYM file which will override the BaseAddress in the GSYM header. GSYM files are easily relocatable by modifying just the base address. This allows GSYM to be used for symbolication much easier by allowing clients to specify the load address of the binary and then do lookups using PC values from a live process.

This option can be used when dumping a full GSYM file, or can also be used when doing lookups via the "--address <addr>" option, or "--addresses-from-stdin" option.

Diff Detail

Event Timeline

clayborg created this revision.Oct 14 2022, 12:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2022, 12:56 PM
clayborg requested review of this revision.Oct 14 2022, 12:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2022, 12:56 PM

The basic flow from the command line is similar to atos:

$ llvm-gsymutil --load-address=0x800000 --address=0x800391 /path/to/a.gsym

I don't know anything about GSYM or llvm-gsymutil really, but this sounds a lot like llvm-symbolizer's --adjust-vma option, but rather than being an offset, it sets the address outright. I guess it doesn't really make sense to follow llvm-symbolizer's option name and behaviour instead of this?

As an aside, I note that llvm-gsymutil doesn't appear to have any CommandGuide documentation in llvm/docs/CommandGuide. Perhaps worth adding at some point...

llvm/include/llvm/DebugInfo/GSYM/GsymReader.h
57

Is the term not "symbolizing" rather than "symbolicating" or is that something else?

232

Ditto.

llvm/test/tools/llvm-gsymutil/X86/elf-dwarf.yaml
6

Nit.

Also, these lines are getting very long. Perhaps it would be worth splitting them up e.g.

# RUN: echo -e ... | \
# RUN:   llvm-gsymutil ... |
# RUN:   FileCheck ...
llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
537

Has been what? Looks like the comment is incomplete to me.

clayborg updated this revision to Diff 468308.Oct 17 2022, 1:53 PM
  • Changed "symbolicating" to "symbolizing" in comments.
  • Changed default value of LoadAddress to be UINT64_MAX to allow clients to be able to specify zero as a load address, and UINT64_MAX would never be a valid load addrss for a binary. Modified a test to test this feature as well.
  • Re-indent the tests ibn elf-dwarf.yaml so the lines are not as long
clayborg marked 4 inline comments as done.Oct 17 2022, 1:57 PM

I don't know anything about GSYM or llvm-gsymutil really, but this sounds a lot like llvm-symbolizer's --adjust-vma option, but rather than being an offset, it sets the address outright. I guess it doesn't really make sense to follow llvm-symbolizer's option name and behaviour instead of this?

It makes more sense to match the "-l" option to atos. Most symbolizing happens on crash logs that either contain load addresses of each shared library and unadjusted PC values, or they contain offsets. I modified the "--load-address" option to be able to have zero set as the value. This allows offsets to be symbolized if "--load-address=0" is set.

As an aside, I note that llvm-gsymutil doesn't appear to have any CommandGuide documentation in llvm/docs/CommandGuide. Perhaps worth adding at some point...

Definitely! I will submit a follow on patch.

You probably should get someone with more knowledge of GSYM/llvm-gsymutil to review the rest of this patch. I've got only one other minor comment.

llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
123

It's probably fine doing this for the "not specified" value, but I'm not a massive fan of it. Is there a cl::opt method that tells you whether an option has actually been specified or not? (If there isn't, or it's not particularly clean, then this is fine)