[PATCH] D71368: [ MC ] Match labels to existing fragments even when switching sections.

Michael Trent via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 11 10:49:27 PST 2019


mtrent created this revision.
mtrent added reviewers: pete, ab, dschuff.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

This commit builds upon Derek Schuff's 2014 commit for attaching labels to
existing fragments ( Diff Revision: http://reviews.llvm.org/D5915 )

When temporary labels appear ahead of a fragment, MCObjectStreamer will
track the temporary label symbol in a "Pending Labels" list. Labels are
associated with fragments when a real fragment arrives; otherwise, an empty
data fragment will be created if the streamer's section changes or if the
stream finishes.

This commit moves the "Pending Labels" list into each MCStream, so that
this label-fragment matching process is resilient to section changes. If
the streamer emits a label in a new section, switches to another section to
do other work, then switches back to the first section and emits a
fragment, that initial label will be associated with this new fragment.
Labels will only receive empty data fragments in the case where no other
fragment exists for that section.

The downstream effects of this can be seen in Mach-O relocations. The
previous approach could produce local section relocations and external
symbol relocations for the same data in an object file, and this mix of
relocation types resulted in problems in the ld64 Mach-O linker. This
commit ensures relocations triggered by temporary labels are consistent.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71368

Files:
  llvm/include/llvm/MC/MCObjectStreamer.h
  llvm/include/llvm/MC/MCSection.h
  llvm/lib/MC/MCObjectStreamer.cpp
  llvm/lib/MC/MCSection.cpp
  llvm/test/MC/MachO/pending-labels.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71368.233413.patch
Type: text/x-patch
Size: 10643 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191211/10085b9e/attachment.bin>


More information about the llvm-commits mailing list