This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] [ARMWinEH] Fix handling of relocations and symbol offsets
ClosedPublic

Authored by mstorsjo on Apr 12 2021, 8:09 AM.

Details

Summary

When looking up data referenced from pdata/xdata structures, the
referenced data can be found in two different ways:

  • For an unrelocated object file, it's located via a relocation
  • For a relocated, linked image, the data is referenced with an (image relative) absolute address

For the latter case, the absolute address can optionally be
described with a symbol.

For the case of an object file, there's two offsets involved; one
immediate offset encoded in the data location that is modified by
the relocation, and a section offset in the symbol.

Previously, for the ExceptionRecord field, we printed the offset
from the symbol (only) but used the immediate offset ignoring
the symbol's address (using only the symbol's section) for printing
the exception data.

Add a helper method for doing the lookup and address calculation,
for simplifying the calling code and making all the cases consistent.

This addresses an existing FIXME comment, fixing printing of the
exception data for cases where relocations point at individual
symbols in the xdata section (which is what MSVC generates) instead of
all relocations pointing at the start of the xdata section (which is
what LLVM generates).

This also fixes printing of the function name for packed entries in
linked images.

Diff Detail

Event Timeline

mstorsjo created this revision.Apr 12 2021, 8:09 AM
mstorsjo requested review of this revision.Apr 12 2021, 8:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2021, 8:09 AM
Herald added a subscriber: MaskRay. · View Herald Transcript
rnk accepted this revision.Apr 29 2021, 12:19 PM

lgtm

llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
254–260

This seems like an overly verbose way to handle errors, but it is the prevailing pattern here, so I won't object to it.

This revision is now accepted and ready to land.Apr 29 2021, 12:19 PM