summaryrefslogtreecommitdiff
path: root/tools/dsymutil
AgeCommit message (Collapse)AuthorFilesLines
2015-03-20Don't declare all text sections at the start of the .sRafael Espindola1-1/+2
The code this patch removes was there to make sure the text sections went before the dwarf sections. That is necessary because MachO uses offsets relative to the start of the file, so adding a section can change relaxations. The dwarf sections were being printed at the start just to produce symbols pointing at the start of those sections. The underlying issue was fixed in r231898. The dwarf sections are now printed when they are about to be used, which is after we printed the text sections. To make sure we don't regress, the patch makes the MachO streamer assert if CodeGen puts anything unexpected after the DWARF sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232842 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17Centralize the handling of unique ids for temporary labels.Rafael Espindola1-6/+4
Before this patch code wanting to create temporary labels for a given entity (function, cu, exception range, etc) had to keep its own counter to have stable symbol names. createTempSymbol would still add a suffix to make sure a new symbol was always returned, but it kept a single counter. Because of that, if we were to use just createTempSymbol("cu_begin"), the label could change from cu_begin42 to cu_begin43 because some other code started using temporary labels. Simplify this by just keeping one counter per prefix and removing the various specialized counters. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232535 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17Convert the last 4 users of GetTempSymbol to createTempSymbol.Rafael Espindola1-2/+2
Despite using the same name these are unrelated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232485 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17Switch two simple uses of GetTempSymbol to createTempSymbol.Rafael Espindola1-2/+2
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232484 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16Pass in a "const Triple &T" instead of a raw StringRef.Rafael Espindola1-1/+1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232429 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16[dsymutil] Add support to generate .debug_pubnames and .debug_pubtypesFrederic Riss1-3/+208
The information gathering part of the patch stores a bit more information than what is strictly necessary for these 2 sections. The rest will become useful when we start emitting __apple_* type accelerator tables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232342 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-15[dsymutil] Add missing raw_svector_stream::resync() calls.Frederic Riss1-3/+4
Also, after looking at the raw_svector_stream internals, increase the size of the SmallString used with it to prevent heap allocation. Issue found by the Asan bot. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232335 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-15[dsymutil] Add support for linking line tables.Frederic Riss1-4/+373
This code comes with a lot of cruft that is meant to mimic darwin's dsymutil behavior. A much simpler approach (described in the numerous FIXMEs that I put in there) gives the right output for the vast majority of cases. The extra corner cases that are handled differently need to be investigated: they seem to correctly handle debug info that is in the input, but that info looks suspicious in the first place. Anyway, the current code needs to handle this, but I plan to revisit it as soon as the big round of validation against the classic dsymutil is over. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232333 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-15[dsymutil] Add an way to iterate over a DebugMapObject symbols.Frederic Riss1-0/+4
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232305 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-15[dsymutil] Add function size to the debug map.Frederic Riss3-12/+27
The debug map embedded by ld64 in binaries conatins function sizes. These sizes are less precise than the ones given by the debug information (byte granularity vs linker atom granularity), but they might cover code that is referenced in the line table but not in the DIE tree (that might very well be a compiler bug that I need to investigate later). Anyway, extracting that information is necessary to be able to mimic dsymutil's behavior exactly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232300 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-14[dsymutil] Add support for debug_loc section.Frederic Riss1-3/+91
There is no need to look into the location expressions to transfer them, the only modification to apply is to patch their base address to reflect the linked function address. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232267 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-14[dsymutil] Generate debug_aranges section.Frederic Riss1-19/+67
This actually shares most of its implementation with the generation of the debug_ranges (the absence of 'a' is not a typo) contribution for the unit's DW_AT_ranges attribute. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232246 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-14[dsymutil] Identify each CompileUnit with a unique ID.Frederic Riss1-4/+8
The ID can eg. de used in MCSymbol names to differentiate the ones that need to be created for every unit. The ID is a constructor parameter and not a static class member so there is no issue with counter updates if we decide to thread that code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232245 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13[dsymutil] Fix typo in comment.Frederic Riss1-1/+1
Next time, when I fix a typo, I'll take the time to reread the whole comment instead of waiting for the commit email to realize that there is another one two words later... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232234 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13[dsymutil] Fix typo in doxygen comment.Frederic Riss1-1/+1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232233 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13[dsymutil] Implement DW_AT_ranges linking.Frederic Riss1-10/+197
Nothing fancy, just a straightforward offset to apply to the original debug_ranges entries to get them in line with the linked addresses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232232 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13[dsymutil] Move a function declaration closer to its peers.Frederic Riss1-1/+1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232231 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13[dsymutil] Fix handling of cross-cu forward references.Frederic Riss1-20/+30
We recorded the forward references in the CU that holds the referenced DIE, but this is wrong as those will get resoled *after* the CU that holds the reference. Record the references in their originating CU along with a pointer to the remote CU to be able to compute the fixed up offset at the right time. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232193 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13[dsymutil] Add relocation of compile_units low_pc/high_pc.Frederic Riss1-16/+43
They need to be handled specifically as they could vary pretty widely depending on how the linker moves functions around. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232192 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13[dsymutil] Fix location cloning for newer dwarf versions.Frederic Riss1-1/+1
The typo got unnoticed because we were testing only on Dwarf 2. Add a Dwarf4 test that exercises the code path, and also tests some newer FORMs that the other test doesn't cover. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232191 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-12Reapply "[dsymutil] Gather function ranges during DIE selection."Frederic Riss1-4/+47
This reverts commit r231967 which reinstates r231957. Now that IntervalMap uses explicitely aligned storage, it should be safe. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232080 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-11Revert "[dsymutil] Gather function ranges during DIE selection."Frederic Riss1-47/+4
This reverts commit r231957. IntervalMap currently doesn't support keys more aligned than host pointers and I've been using it with uint64_t keys. This asserts on some 32bits systems. Revert while I work on an IntervalMap generalization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231967 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-11[dsymutil] Add missing headers.Frederic Riss1-0/+2
No build failure, found by code inspection. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231958 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-11[dsymutil] Gather function ranges during DIE selection.Frederic Riss1-4/+47
Gather the function ranges [low_pc, high_pc) during DIE selection and store them along with the offset to apply to them to get the linked addresses. This is just the data collection part, it comes with no tests. That information will be used in multiple followup commits to perform the relocation of line tables and range sections among other things, and these commits will add tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231957 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-11[dsymutil] Small clang-format patch.Frederic Riss1-2/+2
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231956 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-11[dsymutil] Correctly clone address attributes.Frederic Riss1-14/+73
DW_AT_low_pc on functions is taken care of by the relocation processing, but DW_AT_high_pc and DW_AT_low_pc on other lexical scopes need special handling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231955 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-10Remove the use of the subtarget in MCCodeEmitter creation andEric Christopher1-1/+1
update all ports accordingly. Required a couple of small rewrites in handling subtarget features during creation in PPC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231861 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-07Adding parenthesis around logical expressions to silence a -Wparentheses ↵Aaron Ballman1-2/+2
warning; NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231567 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-07Removing spurious semi-colons; NFCAaron Ballman1-2/+2
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231566 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-07[dsymutil] Apply relocations to DIE data before cloning.Frederic Riss1-1/+68
Doing this gets function's low_pc and global variable's locations right in the output debug info. It also could get right other attributes that need to be relocated (in linker terms), but I don't know of any other than the address attributes. This doesn't fixup low_pc attributes in compile_unit, lexical_block or inlined subroutine, nor does it get right high_pc attributes for function. This will come in a subsequent commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231544 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-06[dsymutil] Support cloning DIE reference attributes.Frederic Riss1-10/+96
Reference attributes are mainly handled by just creating DIEEntry attributes for them. There is a special case for DW_FORM_ref_addr attributes though, because the DIEEntry code needs a DwarfDebug code to emit them (and we don't have one as we do no CodeGen). In that case, just use DIEInteger attributes with the right form. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231531 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-06[dsymutil] Set linked unit start offset early. NFC.Frederic Riss1-7/+8
The start offset of a linked unit is known before starting to clone its DIEs. Handling DW_FORM_ref_addr attributes requires that this offset is set while cloning the unit. Split CompileUnit::computeOffsets() into setStartOffset() and computeNextUnitOffset() and call them repsectively before cloning the DIEs and right after. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231530 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-06[dsymutil] Add debug_str construction support.Frederic Riss1-6/+112
With this comes the ability to correctly clone string attributes in DIEs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231493 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-05Revert "[dsymutil] MSVC does generate move constructors, but it should ↵Frederic Riss1-1/+4
accept to default them" This reverts commit r231350. It turns out MSVC doesn't generate implicit move constructors and also doesn't accept to default them... See for example http://lab.llvm.org:8011/builders/lldb-x86-windows-msvc/builds/2786 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231351 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-05[dsymutil] MSVC does generate move constructors, but it should accept to ↵Frederic Riss1-4/+1
default them git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231350 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-04Provide an explicit move ctor because MSVC can't synthesize oneDavid Blaikie1-0/+6
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231303 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-04[dsymutil] Add minimal code to emit DIE trees.Frederic Riss1-4/+427
This commit adds code to emit DIE trees that have been pruned from the parts that haven't been marked as kept in the previous pass. It works by 'cloning' the input DIE tree (as read by libDebugInfoDwarf) into a tree of DIE objects. Cloning the DIEs means essentially cloning their attributes. The code in this commit does only handle scalar and block attributes (scalar because they are trivial, blocks because they can't be easily replaced by a scalr placeholder), all the other ones are replaced by placeholder zero values and will be handled in further commits. The added tests mostly check that the DIE tree has the correct layout and also verify that a few chosen scalar and block attributes correctly make their way into the output. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231300 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-28[dsymutil] Fully qualify llvm::make_unique<>.Frederic Riss1-2/+3
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230826 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-28[dsymutil] Add the DwarfStreamer class.Frederic Riss6-6/+156
This class is responsible for getting the linked data to the disk in the appropriate form. Today it it an empty shell that just instantiates an MC layer. As we do not put anything in the resulting file yet, we just check it has the right architecture (and check that -o does the right thing). To be able to create all the components, this commit adds a few dependencies to llvm-dsymutil, namely all-targets, MC and AsmPrinter. Also add a -no-output option, so that tests that do not need the binary result can continue to run even if they do not have the required target linked in. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230824 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-28[dsymutil] Add a LinkOptions struct to pass to the DwarfLinker. NFC.Frederic Riss3-14/+26
The only option we have to pass down currently is verbosity, but there are more to come. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230823 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-28[dsymutil] clang-format a fileFrederic Riss1-3/+2
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230822 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-28[dsymutil] Add -o option to select ouptut filenameFrederic Riss1-4/+14
We do not create the output file yet, so no means to test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230821 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-28[dsymutil] Create warn() global helper...Frederic Riss1-3/+8
...and reimplement DwarfLinker::reportWarning in terms of it. Other compenents than the DwarfLinker will need to report warnings, and I'm about to add a similar "error()" helper at the same global level so make that consistent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230820 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-28[dsymutil] Make trivial accessor const.Frederic Riss1-1/+1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230819 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13[dsymutil] Add DIE selection algorithm.Frederic Riss1-1/+320
With this commit, llvm-dsymutil learns how to choose which DIEs it will link in the final output and which ones it won't. This is based on the 'valid relocation' information that has been built in the previous commits. The test only tests that we choose the right 'root DIEs'. The selection algorithm (and especially the part that walk the dependencies of a root DIE) lacks a bit test coverage. This will be much easier to cover when we output actual Dwarf and thus can use llvm-dwarfdump to verify the structure of the emitted DIE trees. I'll add more tests then. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229183 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13[dsymutil] Downcase a function name.Frederic Riss1-4/+4
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229182 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13[dsymutil] Add a few generic helper methods.Frederic Riss1-5/+71
To be used in subsequent commits (separated to keep only core logic in the follow-ups). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229181 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13[dsymutil] constify trivial function.Frederic Riss1-1/+1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229180 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13[dsymutil] Find relocations that correspond to debug map entries.Frederic Riss1-1/+148
These 'valid relocations' in the debug_info section will be how dsymutil identifies the DIEs it needs to keep in the linked debug information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229178 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13[dsymutil] Add DebugMapObject::lookupObjectAddress()Frederic Riss2-3/+22
It turns out the debug map will be interogated both by name and by object file address. Add the latter capability. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229177 91177308-0d34-0410-b5e6-96231b3b80d8