summaryrefslogtreecommitdiffstats
path: root/llvm/tools/yaml2obj/yaml2elf.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Misc improvements to StringTableBuilder.Rafael Espindola2016-10-041-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds write methods to StringTableBuilder so that it is easier to change the underlying implementation. Using the write methods, avoid creating a temporary buffer when using mmaped output. It also uses a more compact key in the DenseMap. Overall this produces a slightly faster lld: firefox master 6.853419709 patch 6.841968912 1.00167361138x faster chromium master 4.297280174 patch 4.298712163 1.00033323147x slower chromium fast master 1.802335952 patch 1.806872459 1.00251701521x slower the gold plugin master 0.3247149 patch 0.321971644 1.00852017888x faster clang master 0.551279945 patch 0.543733194 1.01387951128x faster llvm-as master 0.032743458 patch 0.032143478 1.01866568391x faster the gold plugin fsds master 0.350814247 patch 0.348571741 1.00643341309x faster clang fsds master 0.6281672 patch 0.621130222 1.01132931187x faster llvm-as fsds master 0.030168899 patch 0.029797155 1.01247582194x faster scylla master 3.104222518 patch 3.059590248 1.01458766252x faster llvm-svn: 283266
* Revert "Use getSize instead of data().size(). NFC."Rafael Espindola2016-10-031-1/+1
| | | | | | | | This reverts commit r283125. lld needs to be updated. llvm-svn: 283127
* Use getSize instead of data().size(). NFC.Rafael Espindola2016-10-031-1/+1
| | | | | | | Also assert isFinalized in getSize(). This just reduces the noise from another patch. llvm-svn: 283125
* [yaml2obj] Remove --format option in favor of YAML tagsChris Bieneman2016-06-271-7/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: Our YAML library's handling of tags isn't perfect, but it is good enough to get rid of the need for the --format argument to yaml2obj. This patch does exactly that. Instead of requiring --format, it infers the format based on the tags found in the object file. The supported tags are: !ELF !COFF !mach-o !fat-mach-o I have a corresponding patch that is quite large that fixes up all the in-tree test cases. Reviewers: rafael, Bigcheese, compnerd, silvas Subscribers: compnerd, llvm-commits Differential Revision: http://reviews.llvm.org/D21711 llvm-svn: 273915
* Move ObjectYAML code to a new library.Rafael Espindola2016-03-011-1/+1
| | | | | | | It is only ever used by obj2yaml and yaml2obj. No point in linking it everywhere. llvm-svn: 262368
* Update to use new name alignTo().Rui Ueyama2016-01-141-1/+1
| | | | llvm-svn: 257804
* Add a RAW mode to StringTableBuilder.Rafael Espindola2015-10-231-4/+4
| | | | | | | | | | | | In this mode it just tries to tail merge the strings without imposing any other format constrains. It will not, for example, add a null byte between them. Also add support for keeping a tentative size and offset if we decide to not optimize after all. This will be used shortly in lld for merging SHF_STRINGS sections. llvm-svn: 251153
* [yaml2obj] Support numeric indexes to create invalid files. Will be used by ↵Michael J. Spencer2015-08-271-3/+5
| | | | | | lld test. llvm-svn: 246233
* [yaml2obj] Initialize sh_addralign field for the .symtab sectionSimon Atanasyan2015-07-091-0/+1
| | | | llvm-svn: 241835
* [yaml2obj] Align section content using AddressAlign field's valueSimon Atanasyan2015-07-081-9/+14
| | | | | | | | Use AddressAlign field's value to properly align sections content in the yaml2obj tool. Before this change the yaml2obj ignored AddressAlign and always aligned section on 16 bytes boundary. llvm-svn: 241674
* [ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj toolsSimon Atanasyan2015-07-031-0/+6
| | | | | | | | | | SHT_NOBITS sections do not have content in an object file. Now the yaml2obj tool does not accept `Content` field for such sections, and the obj2yaml tool does not attempt to read the section content from a file. Restore r241350 and r241352. llvm-svn: 241377
* This reverts commit r241350 and r241352.Rafael Espindola2015-07-031-2/+0
| | | | | | | | | | | r241350 broke lld tests. r241352 depends on r241350. Original messages: "[ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj tools" "[ELFYAML] Make the Size field for .bss section optional" llvm-svn: 241354
* [ELFYAML] Fix handling SHT_NOBITS sections by obj2yaml/yaml2obj toolsSimon Atanasyan2015-07-031-0/+2
| | | | | | | | SHT_NOBITS sections do not have content in an object file. Now yaml2obj tool does not accept `Content` field for such sections, and obj2yaml tool does not attempt to read the section content from a file. llvm-svn: 241350
* Simplify now that we always use an alignment of 2 for ELF files.Rafael Espindola2015-06-021-4/+4
| | | | | | This saves 123144 bytes out of llvm-nm on powerpc64le. llvm-svn: 238824
* [yaml2elf] Replace error message by assert call in writeSectionContent methodsSimon Atanasyan2015-05-081-13/+7
| | | | | | | | | Now caller of ELFState::writeSectionContent() methods is responsible to check a section type and selects an appropriate writeSectionContent method. So unexpected section type inside writeSectionContent method indicates a wrong usage of the method and should be guarded by assert. llvm-svn: 236808
* [obj2yaml/yaml2obj] Add SHT_MIPS_ABIFLAGS section supportSimon Atanasyan2015-05-071-0/+37
| | | | | | | This change adds support for the SHT_MIPS_ABIFLAGS section reading/writing to the obj2yaml and yaml2obj tools. llvm-svn: 236738
* Support arm32 R_ARM_V4BX relocation formatAdhemerval Zanella2015-04-221-6/+5
| | | | | | | | | | | | ARM32 ELF R_ARM_V4BX relocation format is a special relocation type that records the location of an ARMv4t BX instruction to enable a static linker to generate ARMv4 compatible instructions. This relocation does not contain a reference symbol. This patch enabled its creation by removing the requeriment of a relocation symbol target in ELFState<ELFT>::writeSectionContent. llvm-svn: 235513
* [obj2yaml/yaml2obj] Add SHT_GROUP support.Shankar Easwaran2015-02-211-0/+44
| | | | | | This adds section group support to the tools obj2yaml and yaml2obj. llvm-svn: 230124
* [ELFYAML] Support mips64 relocation record format in yaml2obj/obj2yamlSimon Atanasyan2015-01-251-2/+8
| | | | | | | | | | | | | | | | | | | MIPS64 ELF file has a very specific relocation record format. Each record might specify up to three relocation operations. So the `r_info` field in fact consists of three relocation type sub-fields and optional code of "special" symbols. http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdf page 40 The patch implements support of the MIPS64 relocation record format in yaml2obj/obj2yaml tools by introducing new optional Relocation fields: Type2, Type3, and SpecSym. These fields are recognized only if the object/YAML file relates to the MIPS64 target. Differential Revision: http://reviews.llvm.org/D7136 llvm-svn: 227044
* Remove StringMap::GetOrCreateValue in favor of StringMap::insertDavid Blaikie2014-11-191-5/+1
| | | | | | | | | | | | | | Having two ways to do this doesn't seem terribly helpful and consistently using the insert version (which we already has) seems like it'll make the code easier to understand to anyone working with standard data structures. (I also updated many references to the Entry's key and value to use first() and second instead of getKey{Data,Length,} and get/setValue - for similar consistency) Also removes the GetOrCreateValue functions so there's less surface area to StringMap to fix/improve/change/accommodate move semantics, etc. llvm-svn: 222319
* [ELF][yaml2obj] Handle additional MIPS specific st_other field flagsSimon Atanasyan2014-11-061-1/+1
| | | | | | | | The ELF symbol `st_other` field might contain additional flags besides visibility ones. This patch implements support for some MIPS specific flags. llvm-svn: 221491
* WinCOFFObjectWriter: optimize the string table for common sufficesHans Wennborg2014-09-291-2/+2
| | | | | | | | This is a follow-up from r207670 which did the same for ELF. Differential Revision: http://reviews.llvm.org/D5530 llvm-svn: 218636
* Invert the MC -> Object dependency.Rafael Espindola2014-07-031-1/+1
| | | | | | | | | Now that we have a lib/MC/MCAnalysis, the dependency was there just because of two helper classes. Move the two over to MC. This will allow IRObjectFile to parse inline assembly. llvm-svn: 212248
* [yaml2obj][obj2yaml] Support ELF symbol's visibility flags ↵Simon Atanasyan2014-06-061-0/+1
| | | | | | (default/hidden/protected). llvm-svn: 210316
* [yaml2obj] Add new command line option `-docnum`.Simon Atanasyan2014-05-311-2/+1
| | | | | | | | | | Input YAML file might contain multiple object file definitions. New option `-docnum` allows to specify an ordinal number (starting from 1) of definition used for an object file generation. Patch reviewed by Sean Silva. llvm-svn: 209967
* [yaml2obj][ELF] Add an optional `Size` field to the YAML section declaration.Simon Atanasyan2014-05-161-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now the only method to configure ELF section's content and size is to assign a hexadecimal string to the `Content` field. Unfortunately this way is completely useless when you need to declare a really large section. To solve this problem this patch adds one more optional field `Size` to the `RawContentSection` structure. When yaml2obj generates an ELF file it uses the following algorithm: 1. If both `Content` and `Size` fields are missed create an empty section. 2. If only `Content` field is missed take section length from the `Size` field and fill the section by zero. 3. If only `Size` field is missed create a section using data from the `Content` field. 4. If both `Content` and `Size` fields are provided validate that the `Size` value is not less than size of `Content` data. Than take section length from the `Size`, fill beginning of the section by `Content` and the rest by zero. Examples -------- * Create a section 0x10000 bytes long filled by zero Name: .data Type: SHT_PROGBITS Flags: [ SHF_ALLOC ] Size: 0x10000 * Create a section 0x10000 bytes long starting from 'CA' 'FE' 'BA' 'BE' Name: .data Type: SHT_PROGBITS Flags: [ SHF_ALLOC ] Content: CAFEBABE Size: 0x10000 The patch reviewed by Michael Spencer. llvm-svn: 208995
* [yaml2obj] Add "-o" command line option to specify an output file name.Simon Atanasyan2014-05-151-4/+4
| | | | llvm-svn: 208900
* Use the new StringTableBuilder in yaml2elfHans Wennborg2014-04-301-45/+27
| | | | | | http://reviews.llvm.org/D3574 llvm-svn: 207694
* ELFObjectWriter: deduplicate suffices in strtabHans Wennborg2014-04-301-4/+2
| | | | | | | | | | | | | | | We already do this for shstrtab, so might as well do it for strtab. This extracts the string table building code into a separate class. The idea is to use it for other object formats too. I mostly wanted to do this for the general principle, but it does save a little bit on object file size. I tried this on a clang bootstrap and saved 0.54% on the sum of object file sizes (1.14 MB out of 212 MB for a release build). Differential Revision: http://reviews.llvm.org/D3533 llvm-svn: 207670
* [yaml2obj][ELF] ELF Relocations Support.Simon Atanasyan2014-04-111-16/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The patch implements support for both relocation record formats: Elf_Rel and Elf_Rela. It is possible to define relocation against symbol only. Relocations against sections will be implemented later. Now yaml2obj recognizes X86_64, MIPS and Hexagon relocation types. Example of relocation section specification: Sections: - Name: .text Type: SHT_PROGBITS Content: "0000000000000000" AddressAlign: 16 Flags: [SHF_ALLOC] - Name: .rel.text Type: SHT_REL Info: .text AddressAlign: 4 Relocations: - Offset: 0x1 Symbol: glob1 Type: R_MIPS_32 - Offset: 0x2 Symbol: glob2 Type: R_MIPS_CALL16 The patch reviewed by Michael Spencer, Sean Silva, Shankar Easwaran. llvm-svn: 206017
* [yaml2obj][ELF] Rename class SectionNameToIdxMap => NameToIdxMap. It canSimon Atanasyan2014-04-061-10/+10
| | | | | | | | be used for indexing not only section's names. No functional changes. llvm-svn: 205687
* [yaml2obj][ELF] Convert some static functions into class members toSimon Atanasyan2014-04-021-149/+159
| | | | | | | | reduce number of arguments. No functional changes. llvm-svn: 205434
* [yaml2obj][ELF] Remove unused typedef.Simon Atanasyan2014-04-021-1/+0
| | | | | | No functional changes. llvm-svn: 205433
* [yaml2obj][ELF] Move section index to the ELFState class.Simon Atanasyan2014-04-021-32/+39
| | | | | | No functional changes. llvm-svn: 205432
* [yaml2obj][ELF] Remove relationship between ELFStateSimon Atanasyan2014-04-021-13/+6
| | | | | | | | | and ContiguousBlobAccumulator classes. Pass ContiguousBlobAccumulator to the handleSymtabSectionHeader function directly. No functional changes. llvm-svn: 205431
* [yaml2obj] Add support for ELF e_flags.Daniel Sanders2014-03-311-0/+1
| | | | | | | | | | | | | | | | Summary: The FileHeader mapping now accepts an optional Flags sequence that accepts the EF_<arch>_<flag> constants. When not given, Flags defaults to zero. Reviewers: atanasyan Reviewed By: atanasyan CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3213 llvm-svn: 205173
* [yaml2obj][ELF] Use range-based for loops.Simon Atanasyan2014-03-141-4/+2
| | | | llvm-svn: 203900
* [yaml2obj][ELF] Refer to a section in the error message by its name notSimon Atanasyan2014-03-141-1/+1
| | | | | | index. llvm-svn: 203899
* [yaml2obj][ELF] Remove unused ELFState class field.Simon Atanasyan2014-03-141-7/+4
| | | | llvm-svn: 203898
* [yaml2obj][ELF] Assign name (.shstrtab) to the section holds sections names.Simon Atanasyan2014-03-141-0/+1
| | | | llvm-svn: 203897
* yaml2coff/elf: Touchup for compatibility.Will Dietz2013-10-121-7/+9
| | | | | | | * std::string::append(int, int) can be ambiguous. * std::vector<>::data() is a C++11 feature, use ArrayRef abstraction. llvm-svn: 192542
* [Object] Split the ELF interface into 3 parts.Michael J. Spencer2013-08-081-10/+11
| | | | | | | | * ELFTypes.h contains template magic for defining types based on endianess, size, and alignment. * ELFFile.h defines the ELFFile class which provides low level ELF specific access. * ELFObjectFile.h contains ELFObjectFile which uses ELFFile to implement the ObjectFile interface. llvm-svn: 188022
* [yaml2obj][ELF] Make symbol table top-level key.Sean Silva2013-06-221-9/+11
| | | | | | | | | Although in reality the symbol table in ELF resides in a section, the standard requires that there be no more than one SHT_SYMTAB. To enforce this constraint, it is cleaner to group all the symbols under a top-level `Symbols` key on the object file. llvm-svn: 184627
* [yaml2obj][ELF] Narrow parameter.Sean Silva2013-06-221-6/+6
| | | | | | The full ELFYAML::Section isn't needed. llvm-svn: 184626
* [yaml2obj][ELF] Don't special case writing these.Sean Silva2013-06-221-2/+2
| | | | | | | Just add them to the vector of section headers like the rest of the section headers. llvm-svn: 184624
* [yaml2obj][ELF] Make this "type switch" actually readable.Sean Silva2013-06-221-7/+20
| | | | llvm-svn: 184623
* [yaml2obj][ELF] Align section contents in the output.Sean Silva2013-06-221-8/+17
| | | | | | | | | | The improperly aligned section content in the output was causing buildbot failures. This should fix them. Incidentally, this results in a simpler and more robust API for ContiguousBlobAccumulator. llvm-svn: 184621
* [yaml2obj][ELF] Allow expressing undefined symbols.Sean Silva2013-06-211-7/+9
| | | | | | | | | | Previously we unconditionally enforced that section references in symbols in the YAML had a name that was a section name present in the object, and linked the references to that section. Now, permit empty section names (already the default, if the `Section` key is not provided) to indicate SHN_UNDEF. llvm-svn: 184513
* Unbreak bots. Didn't realize this was a C++11 feature.Sean Silva2013-06-211-5/+6
| | | | llvm-svn: 184508
* [yaml2obj][ELF] Don't explicitly set `Binding` with STB_*Sean Silva2013-06-211-24/+33
| | | | | | | | | | | | | | | Instead, just have 3 sub-lists, one for each of {STB_LOCAL,STB_GLOBAL,STB_WEAK}. This allows us to be a lot more explicit w.r.t. the symbol ordering in the object file, because if we allowed explicitly setting the STB_* `Binding` key for the symbol, then we might have ended up having to shuffle STB_LOCAL symbols to the front of the list, which is likely to cause confusion and potential for error. Also, this new approach is simpler ;) llvm-svn: 184506
OpenPOWER on IntegriCloud