Commit Graph

428 Commits

Author SHA1 Message Date
Rafael Espindola
24441414a3 Remove temporary FileSymbolData. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238461 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-28 19:29:15 +00:00
Rafael Espindola
fd64e0f71a Use range loops for accessing file names. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238446 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-28 18:03:20 +00:00
Rafael Espindola
b9ffeb0979 Merge computeSymbolTable and writeSymbolTable.
For now this just saves a few loops, but it will allow more simplifications
in the future.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238444 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-28 17:54:01 +00:00
Rafael Espindola
c4e38f605e Don't create an unused _GLOBAL_OFFSET_TABLE_.
This was a bug for bug compatibility with gas that is completely unnecessary.
If a _GLOBAL_OFFSET_TABLE_ symbol is used, it will already be created by
the time we get to the ELF writer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238432 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-28 15:20:00 +00:00
Rafael Espindola
41cea417fa There is only one current section.
Both MCStreamer and MCObjectStreamer were maintaining a current section
variable and they were slightly out of sync. I don't think this was observable,
but was inefficient and error prone.

Changing this requires a few cascading changes:

* SwitchSection has to call ChangeSection earlier for ChangeSection to see
  the old section.
* With that change, ChangeSection cannot call EmitLabel, since during
  ChangeSection we are still in the old section.
* When the object streamer requires a begin label, just reused the existing
  generic support for begin labels instead of calling EmitLabel directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238357 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 20:52:32 +00:00
Rafael Espindola
899cab6126 Delete MCSectionData.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238331 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 15:14:11 +00:00
Rafael Espindola
a287fe7fa0 Remove uses of MCSectionData from ELFObjectWriter. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238317 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 13:30:50 +00:00
Rafael Espindola
2224f64c6d Remove most uses of MCSectionData from MCAssembler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238172 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 02:17:21 +00:00
Rafael Espindola
ea3533b4c6 Stop using MCSectionData in MCAsmLayout.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238170 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 02:00:36 +00:00
Rafael Espindola
f363960679 Return a MCSection from MCFragment::getParent().
Another step in merging MCSectionData and MCSection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238162 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 00:36:57 +00:00
Rafael Espindola
e86bc46939 Turn MCSectionData into a field of MCSection.
This also changes MCAssembler to store a vector of MCSections instead of an
iplist of MCSectionData.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238159 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-25 23:14:17 +00:00
Rafael Espindola
ab78d67435 Make a few MCSectionELF& variables const. NFC.
This just reduces the noise from another patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238156 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-25 21:56:55 +00:00
Rafael Espindola
7c4f3dcc5e Produce a single string table in a ELF .o
Normally an ELF .o has two string tables, one for symbols, one for section
names.

With the scheme of naming sections like ".text.foo" where foo is a symbol,
there is a big potential saving in using a single one.

Building llvm+clang+lld with master and with this patch the results were:

master:                          193,267,008 bytes
patch:                           186,107,952 bytes
master non unique section names: 183,260,192 bytes
patch non unique section names:  183,118,632 bytes

So using non usique saves 10,006,816 bytes, and the patch saves 7,159,056 while
still using distinct names for the sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238073 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-22 23:58:30 +00:00
Duncan P. N. Exon Smith
6c3a7cbe54 MC: Lift MCSymbolData::Index up to MCSymbol::Index, NFC
Lift `MCSymbolData::Index` up a level to `MCSymbol`, as preparation for
packing it into the bitfield in `MCSymbol`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238001 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-22 05:54:01 +00:00
Rafael Espindola
477acf64d0 Stop forwarding (get|set)Aligment from MCSectionData to MCSection.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237956 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 21:02:35 +00:00
Rafael Espindola
fabbc4985b Stop creating MCSectionData is the ELF writer.
Now is is just its use of MCSymbolData that requires it to take a non const
MCAssembler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237951 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 20:43:13 +00:00
Rafael Espindola
3b294b5753 writeSymbolTable now only needs a MCContext.
It used to use an MCAssembler just to record the alignment of the sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237944 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 19:54:44 +00:00
Rafael Espindola
9a9984d0b5 Pass a const MCAssembler to writeSectionHeader.
It never creates sections, so it can use Asm.getSectionData instead of
Asm.getOrCreateSectionData.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237943 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 19:46:39 +00:00
Rafael Espindola
a127bd0585 Remove unused argument. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 19:42:35 +00:00
Rafael Espindola
ad7c1174c7 Fetch alignment directly out of MCSection. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237938 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 19:36:43 +00:00
Rafael Espindola
7521964d28 Move alignment from MCSectionData to MCSection.
This starts merging MCSection and MCSectionData.

There are a few issues with the current split between MCSection and
MCSectionData.

* It optimizes the the not as important case. We want the production
of .o files to be really fast, but the split puts the information used
for .o emission in a separate data structure.

* The ELF/COFF/MachO hierarchy is not represented in MCSectionData,
leading to some ad-hoc ways to represent the various flags.

* It makes it harder to remember where each item is.

The attached patch starts merging the two by moving the alignment from
MCSectionData to MCSection.

Most of the patch is actually just dropping 'const', since
MCSectionData is mutable, but MCSection was not.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237936 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 19:20:38 +00:00
Duncan P. N. Exon Smith
f5bdf04f09 MC: Use MCSymbol in MCObjectWriter::isWeak(), NFC
Continue to prefer `MCSymbol` when we need both.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237798 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 15:10:03 +00:00
Duncan P. N. Exon Smith
37e9aba0db MC: Use MCSymbol in most of ELFObjectWriter, NFC
Stop using MCSymbolData where we also need MCSymbol.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237770 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 04:39:01 +00:00
Duncan P. N. Exon Smith
e1fce8692d MC: Use MCSymbol in MCAsmLayout::getSymbolOffset(), NFC
Continue to canonicalize on MCSymbol instead of MCSymbolData when both
are needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237749 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-19 23:53:20 +00:00
Jim Grosbach
19696daa21 MC: Clean up method names in MCContext.
The naming was a mish-mash of old and new style. Update to be consistent
with the new. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237594 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-18 18:43:14 +00:00
Duncan P. N. Exon Smith
9e6378de57 MC: Use MCSymbol in MCObject::IsSymbolRefDifferenceFullyResolvedImpl()
Transition one API from `MCSymbolData` to `MCSymbol`.  The function
needs both, and the backpointer from `MCSymbolData` to `MCSymbol` is
going away.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237498 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-16 01:01:55 +00:00
Duncan P. N. Exon Smith
a5bb842d95 MC: Change MCAssembler::Symbols to store MCSymbol, NFC
Instead of storing a list of the `MCSymbolData` in use, store the
`MCSymbol`s.  Churning in the direction of removing the back pointer
from `MCSymbolData`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237496 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-16 00:35:24 +00:00
Yaron Keren
e49e65326a Update ELFObjectWriter::reset() following r236255.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237261 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-13 15:17:19 +00:00
Rafael Espindola
b6b3a92b97 Remove unnecessary break.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236275 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 22:41:12 +00:00
Rafael Espindola
a55dd52dc8 Simplify the creation of compressed debug sections.
This is actually fairly simple in the current code layout: Check if we should
compress just before writing out and everything else just works.

This removes the last case in which the object writer was creating a
fragment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236267 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 21:51:58 +00:00
Rafael Espindola
15953ff2df Replace unreachable code with llvm_unreachable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236261 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 21:20:06 +00:00
Rafael Espindola
d80f5165d1 Don't create a MCSectionData when we don't have to.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236260 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 21:10:06 +00:00
Rafael Espindola
494f112fbc Avoid an extra loop over the sections.
Add string to the section header string table as we add sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236257 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 20:57:14 +00:00
Rafael Espindola
b65870f3f5 Make the section table a member of ELFObjectWriter.
This avoids passing it around and lets us build a small helper to add
a section to the table.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236255 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 20:53:27 +00:00
Rafael Espindola
4ed1491bc9 Nothing inherits from this, drop the protected:
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236253 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 20:37:36 +00:00
Rafael Espindola
76e71bd66e Write sections mostly in one pass.
During ELF writing, there is no need to further relax the sections, so we
should not be creating fragments. This patch avoids doing so in all cases
but debug section compression (that is next).

Also, the ELF format is fairly simple to write. We can do a single pass over
the sections to write them out and compute the section header table.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236235 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 14:21:49 +00:00
Aaron Ballman
8c54c84ae7 Silencing an "enumeral and non-enumeral type in conditional expression" warning; NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236234 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 14:03:12 +00:00
Rafael Espindola
4689501178 Store relocations in a map from MCSectionELF.
Saves finding the MCSectionData just to do a map lookup.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236189 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 00:45:46 +00:00
Rafael Espindola
1e95f2152f Write relocations directly to the output stream. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236187 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 00:30:40 +00:00
Rafael Espindola
a19abeb7ab Inline FragmentWriter into the only user.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236158 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 21:13:30 +00:00
Rafael Espindola
5fc3769ddc Write the symbol table directly to the output file.
There is no need to first accumulate it in fragments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236157 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 21:09:32 +00:00
Rafael Espindola
840bb0f332 Use pwrite to write the number of sections.
This avoids having to compute the number upfront, which will be used in the
next patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236153 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 20:39:37 +00:00
Rafael Espindola
4fa3a17472 Write the string table directly to the output file.
There is no need to accumulate it in fragments first.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236148 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 20:34:31 +00:00
Rafael Espindola
58a854d447 Write the section header string table directly to the output stream.
Instead of accumulating the content in a fragment first, just write it
to the output stream.

Also put it first in the section table, so that we never have to worry
about its index being >= SHN_LORESERVE.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236145 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 20:25:24 +00:00
Rafael Espindola
4a43cd24af Avoid a few const_cast.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236141 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 19:20:10 +00:00
Rafael Espindola
5acccb16a8 Map directly from signature symbol to group index. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236058 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 22:59:58 +00:00
Rafael Espindola
b89275550c Remove redundant temporary std::vector.
New sections are added to the end of the list, so the RelSections array was
redundant.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236053 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 22:26:19 +00:00
Rafael Espindola
f75160b8d9 Avoid one more walk over all sections. NFC.
Set the group section index as they are created.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236049 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 22:03:22 +00:00
Rafael Espindola
7aff72189a Use a range loop. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236047 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 21:58:05 +00:00
Rafael Espindola
f23613a3cd Avoid an extra walk over the sections just to assign sections to groups.
Assign the sections in the same pass we compute the index.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236045 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 21:52:33 +00:00