[PATCH] Add support for subsections to the ELF assembler. Fixes PR8717.
Rafael Ávila de Espíndola
rafael.espindola at gmail.com
Tue Apr 9 13:30:35 PDT 2013
My first thought was "why not use one fragment list per subsection", but then I tried
.text
.subsection 1
foo:
jmp bar
.subsection 2
bar:
nop
and gas produced:
0000000000000000 <foo>:
0: eb 00 jmp 2 <bar>
0000000000000002 <bar>:
2: 90 nop
This implies that subsections are not only not aligned (as you noticed), but all subsections in a section are relaxed in one group, so your design of one frament list with multiple insertion points is correct. Please add a test showing this.
Please make sure we reject numbers larger than 8192.
================
Comment at: include/llvm/MC/MCAssembler.h:596
@@ +595,3 @@
+ /// below that number.
+ std::map<int64_t, MCFragment *> SubsectionFragmentMap;
+
----------------
Subsections are a number from 0 to 8192, there has to be a better map for this :-)
Given that most files will not have many subsections, a sorted SmallVector will probably do.
================
Comment at: lib/MC/MCObjectStreamer.cpp:179
@@ +178,3 @@
+ !Subsection->EvaluateAsAbsolute(IntSubsection, getAssembler()))
+ report_fatal_error("Cannot evaluate subsection number");
+ CurInsertionPoint =
----------------
Can we report the error without using report_fatal_error?
================
Comment at: include/llvm/MC/MCObjectStreamer.h:63
@@ +62,3 @@
+ CurSectionData->getFragmentList().insert(CurInsertionPoint, F);
+ F->setParent(CurSectionData);
+ }
----------------
Currently setParent is unused. The default sectiondata values are also unused. Instead of creating dangling fragments that have to immediately be passed to insert, could you change the MCFragment constructor to take an insertion point?
http://llvm-reviews.chandlerc.com/D598
More information about the llvm-commits
mailing list