1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

2358 Commits

Author SHA1 Message Date
Saleem Abdulrasool
7a571c0be3 MC: place .file records into the correct section
.file records are supposed to have a section identifier of 65534
(IMAGE_SCN_DEBUG) rather than 0.  This is spelt out clearly within the PE/COFF
specification.  Fix this minor oversight with the implementation for support for
.file records.

llvm-svn: 207851
2014-05-02 17:45:24 +00:00
David Blaikie
6383ec4a59 Fix uninitialized variable introduced in r207739.
This was initialized by llvm-mc (calling setDwarfVersion) but other
clients (such as clang, llc, etc) aren't necessarily initializing this
so we were getting garbage DWARF version values in the output.
Initialize it to a reasonable default (the same default used in llvm-mc,
though this is higher than it was (2) previously).

llvm-svn: 207788
2014-05-01 19:55:34 +00:00
Rafael Espindola
f27adbd4c2 Don't propagate StorageClass and ComplexType to aliases.
This matches gas' behaviour on COFF.

I think that this yak is now sufficiently shaved for aliases with offset
to work.

llvm-svn: 207786
2014-05-01 19:02:03 +00:00
Rafael Espindola
4ce7e8e6df Compute the correct section for zed = foo + 1 in COFF.
This fixes pr19147.

There are a few more related issues to fix, but the testcase in the bug now
passes.

llvm-svn: 207763
2014-05-01 13:37:57 +00:00
Rafael Espindola
6b3eacf852 Move getBaseSymbol somewhere the COFF writer can use.
I will use it there in a second.

llvm-svn: 207761
2014-05-01 13:24:25 +00:00
Rafael Espindola
bcaa0dd2f9 Make getBaseSymbol non recursive.
llvm-svn: 207759
2014-05-01 13:09:42 +00:00
Oliver Stannard
0d1466e7c9 Record the DWARF version in MCContext
Record the DWARF version in MCContext, and use it when
emitting the dwarf version into the debug info.

llvm-svn: 207739
2014-05-01 08:46:02 +00:00
Rafael Espindola
6ed44fb3d0 Start fixing pr19147.
This makes the coff writer compute the correct symbol value for the test in
pr19147. The section is still incorrect, that will be fixed in a followup patch.

llvm-svn: 207728
2014-05-01 00:10:17 +00:00
Joerg Sonnenberger
931f18107d Add missing breaks.
llvm-svn: 207723
2014-04-30 23:36:24 +00:00
Joerg Sonnenberger
443277a751 Switch over getArch()'s result.
llvm-svn: 207721
2014-04-30 23:23:14 +00:00
Rafael Espindola
619f759608 Provide a version of getSymbolOffset that returns false on error.
This simplifies ELFObjectWriter::SymbolValue a bit more. This new version
will also be used in the COFF writer to fix pr19147.

llvm-svn: 207711
2014-04-30 21:51:13 +00:00
Rafael Espindola
df3c13c420 Simplify ELFObjectWriter::SymbolValue.
It now defers all offset computation to getSymbolOffset.

llvm-svn: 207674
2014-04-30 16:59:35 +00:00
Hans Wennborg
1f76d4c2b7 ELFObjectWriter: deduplicate suffices in strtab
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
2014-04-30 16:25:02 +00:00
Rafael Espindola
492391e686 Grammar fix.
Thanks to Saleem Abdulrasool for noticing it.

llvm-svn: 207643
2014-04-30 12:42:22 +00:00
James Molloy
b41c043c3c [ARM64] Ensure arm64_be is dealt with when emitting debug info.
This is a partial port of r204816 (cpirker "Elf support for MC-JIT
runtime dynamic linker") from AArch64 to ARM64.

llvm-svn: 207625
2014-04-30 10:15:35 +00:00
Rafael Espindola
cc84bed91a Simplify getSymbolOffset.
We can now use EvaluateAsValue to make it non recursive and remove some code
duplication.

llvm-svn: 207604
2014-04-30 03:06:06 +00:00
Benjamin Kramer
b1deb46708 Another missing include for MSVC.
llvm-svn: 207596
2014-04-29 23:46:48 +00:00
Benjamin Kramer
4f8fb8ff6c raw_ostream: Forward declare OpenFlags and include FileSystem.h only where necessary.
llvm-svn: 207593
2014-04-29 23:26:49 +00:00
Joerg Sonnenberger
2978bd4236 Parse and create GOT_PREL relocations.
llvm-svn: 207526
2014-04-29 13:42:02 +00:00
Rafael Espindola
ea5c91adc8 Centralize the handling of the thumb bit.
This patch centralizes the handling of the thumb bit around
MCStreamer::isThumbFunc and makes isThumbFunc handle aliases.

This fixes a corner case, but the main advantage is having just one
way to check if a MCSymbol is thumb or not. This should still be
refactored to be ARM only, but at least now it is just one predicate
that has to be refactored instead of 3 (isThumbFunc,
ELF_Other_ThumbFunc, and SF_ThumbFunc).

llvm-svn: 207522
2014-04-29 12:46:50 +00:00
Rafael Espindola
1fe9e6bc34 Add an option for evaluating past symbols.
When evaluating an assembly expression for a relocation, we want to
stop at MCSymbols that are in the symbol table, even if they are variables.
This is needed since the semantics may require that the relocation use them.

That is not the case when computing the value of a symbol in the symbol table.
There are no relocations in this case and we have to keep going until we hit
a section or find out that the expression doesn't have an assembly time
value.

llvm-svn: 207445
2014-04-28 20:53:11 +00:00
Rafael Espindola
b2d0a296c4 Simplify ELFObjectWriter::ExecutePostLayoutBinding.
No functionality change. This removes the last use of AliasedSymbol in
ELFObjectWriter.cpp.

llvm-svn: 207424
2014-04-28 17:05:36 +00:00
Rafael Espindola
9efc666a93 Simplify isLocal().
No functionality change.

llvm-svn: 207421
2014-04-28 14:24:44 +00:00
Rafael Espindola
4d0ea07e27 Don't include an invalid symbol in the symbol table.
The symbol table itself has no relocations, so it is not possible to represent
things like

a = undefined + 1

With the patch we just omit these variables. That matches the behaviour of the
gnu assembler.

llvm-svn: 207419
2014-04-28 13:39:57 +00:00
Rafael Espindola
55789b6ba9 Produce an error instead of a crash in an expr we cannot represent.
llvm-svn: 207414
2014-04-28 12:40:50 +00:00
Saleem Abdulrasool
781a0bae0e MC: range-loopify
Use C++11 range-based loops rather than explicit constructors.  NFC.

llvm-svn: 207393
2014-04-28 03:34:48 +00:00
Rafael Espindola
a787d5eaac Make getOrCreateSymbolData non virtual.
llvm-svn: 207367
2014-04-27 17:23:37 +00:00
Rafael Espindola
947137e8a0 Avoid using MCSymbolData on the asm streamer.
Only the object streamers need to track if a symbol should be marked thumb or
not. This ports the ELF case. The COFF case is not ported since it is currently
not working for some other reason (I will report a bug).

llvm-svn: 207366
2014-04-27 17:10:46 +00:00
Saleem Abdulrasool
a8ba3a2407 MC: restore behaviour of defaulting to ELF
This restores the previous behaviour of just assuming that if you dont specify a
valid triple that you really meant the default triple with an ELF object file.

llvm-svn: 207349
2014-04-27 04:54:16 +00:00
Saleem Abdulrasool
7ece6ce430 Add WoA object file emission support
Introduce support for WoA PE/COFF object file emission from LLVM.  Add the new
target specific PE/COFF Streamer (ARMWinCOFFStreamer) that handles the ARM
specific behaviour of PE/COFF object emission.  ARM exception information is not
yet emitted and is a TODO item.

The ARM specific object writer (ARMWinCOFFObjectWriter) handles the ARM specific
relocation handling in conjunction with the WinCOFFObjectWriter in the MC layer.
The MC layer needs to be updated to deal with the relocation adjustments.
Branch relocations are adjusted by 4 bytes (unlikely their ELF counterparts).

Minor tweaks to switch multiple conditional checks into equivalent switch
statements.  The ObjectFileInfo is updated to relax the object file setup for
Windows COFF.  Move the architecture checks into an assertion.  Windows COFF is
currently only supported on x86, x86_64, and ARM (thumb).  Rather than
defaulting to ELF, we will refuse to generate an object file.  This is better
though as you do not get an (arbitrary) object file which is different from the
request.

llvm-svn: 207345
2014-04-27 03:48:22 +00:00
Saleem Abdulrasool
a5ef2286b3 MC: create X86WinCOFFStreamer for target specific behaviour
This introduces a target specific streamer, X86WinCOFFStreamer, which handles
the target specific behaviour (e.g. WinEH).  This is mostly to ensure that
differences between ARM and X86 remain disjoint and do not accidentally cross
boundaries.  This is the final staging change for enabling object emission for
Windows on ARM.

llvm-svn: 207344
2014-04-27 03:48:12 +00:00
Saleem Abdulrasool
c1c504d313 MC: rename WinCOFFStreamer and move declaration out-of-line
This is in preparation for promoting WinCOFFStreamer to a base class which will
be shared by the X86 and ARM specific target COFF streamers.  Also add a new
getOrCreateSymbolData interface (like MCELFStreamer) for the ARM COFF Streamer.
This makes the COFFStreamer more similar to the ELFStreamer.

llvm-svn: 207343
2014-04-27 03:48:05 +00:00
Saleem Abdulrasool
46f54b28d4 MC: style tweaks to WinCOFFStreamer
Stylistic changes to prepare for splitting up the COFFStreamer into target
specific streamers.  Tweak some assertion messages.  No functional change.

llvm-svn: 207342
2014-04-27 03:48:01 +00:00
David Blaikie
32a1942110 Fix quadratic performance during debug compression due to sections x symbols iteration.
When fixing the symbols in each compressed section we were iterating
over all symbols for each compressed section. In extreme cases this
could snowball severely (5min uncompressed -> 35min compressed) due to
iterating over all symbols for each compressed section (large numbers of
compressed sections can be generated by DWARF type units).

To address this, build a map of the symbols in each section ahead of
time, and access that map if a section is being compressed. This brings
compile time for the aforementioned example down to ~6 minutes.

llvm-svn: 207167
2014-04-25 00:48:01 +00:00
David Blaikie
52ea9cc073 Spread some const around for non-mutating uses of MCSymbolData.
I discovered this const-hole while attempting to coalesnce the Symbol
and SymbolMap data structures. There's some pending issues with that,
but I figured this change was easy to flush early.

llvm-svn: 207124
2014-04-24 16:59:40 +00:00
David Blaikie
2786c0551f Fix memory leak of MCSymbolData in MCAsmStreamer.
Leak identified by LSan and reported by Kostya Serebryany.

Let's get a bit experimental here... in theory our minimum compiler
versions support unordered_map.

llvm-svn: 207118
2014-04-24 14:33:36 +00:00
Craig Topper
c7c3a99ec2 [C++] Use 'nullptr'.
llvm-svn: 207083
2014-04-24 06:44:33 +00:00
Saleem Abdulrasool
171f112dca MC: honour IMAGE_SCN_CNT_INITIALIZED_DATA
Emit the flag to indicate to the assembler that a section contains data if there
is pre-populated data present.

llvm-svn: 207028
2014-04-23 21:29:34 +00:00
Rafael Espindola
3b222f0320 Centralize handling of ELF_Other_ThumbFunc.
No functionality change.

llvm-svn: 206988
2014-04-23 14:42:32 +00:00
Evgeniy Stepanov
c242bd4b23 Create MCTargetOptions.
For now it contains a single flag, SanitizeAddress, which enables
AddressSanitizer instrumentation of inline assembly.

Patch by Yuri Gorshenin.

llvm-svn: 206971
2014-04-23 11:16:03 +00:00
Stepan Dyatkovskiy
70097dbad7 Integrated assbemler, macros: added 'vararg' argument qualifier support.
Note, currently we have no 'vararg' support for darwin macros.

llvm-svn: 206951
2014-04-23 06:56:28 +00:00
Kevin Enderby
af08119374 Change the prototype for MCContext::FatalError() so it can be called
from places like MCCodeEmitter() in the MC backend when the
MCContext is const.

I was going to use this in my change for r206669 but Jim convinced
me to use an assert there. But this still is a good tweak.

llvm-svn: 206923
2014-04-22 21:42:18 +00:00
Rafael Espindola
37853f597b Follow aliases when determining if a symbol is thumb.
This fixes pr19484.

llvm-svn: 206917
2014-04-22 19:11:07 +00:00
Kevin Enderby
223e66dc63 Fix the assembler to print a better relocatable expression error
diagnostic that includes location information.

Currently if one has this assembly:

	.quad (0x1234 + (4 * SOME_VALUE))

where SOME_VALUE is undefined ones gets the less than
useful error message with no location information:

% clang -c x.s
clang -cc1as: fatal error: error in backend: expected relocatable expression

With this fix one now gets a more useful error message
with location information:

% clang -c x.s 
x.s:5:8: error: expected relocatable expression
 .quad (0x1234 + (4 * SOME_VALUE))
       ^

To do this I plumbed the SMLoc through the MCObjectStreamer
EmitValue() and EmitValueImpl() interfaces so it could be used
when creating the MCFixup.

rdar://12391022

llvm-svn: 206906
2014-04-22 17:27:29 +00:00
NAKAMURA Takumi
3a13d3a710 Remove DOS CRLF.
llvm-svn: 206894
2014-04-22 13:35:50 +00:00
Chandler Carruth
3b7bc6ca91 [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE
definition below all the header #include lines. This updates most of the
miscellaneous other lib/... directories. A few left though.

llvm-svn: 206845
2014-04-22 03:04:17 +00:00
Chandler Carruth
15c7b91ac2 [Modules] Make Support/Debug.h modular. This requires it to not change
behavior based on other files defining DEBUG_TYPE, which means it cannot
define DEBUG_TYPE at all. This is actually better IMO as it forces folks
to define relevant DEBUG_TYPEs for their files. However, it requires all
files that currently use DEBUG(...) to define a DEBUG_TYPE if they don't
already. I've updated all such files in LLVM and will do the same for
other upstream projects.

This still leaves one important change in how LLVM uses the DEBUG_TYPE
macro going forward: we need to only define the macro *after* header
files have been #include-ed. Previously, this wasn't possible because
Debug.h required the macro to be pre-defined. This commit removes that.
By defining DEBUG_TYPE after the includes two things are fixed:

- Header files that need to provide a DEBUG_TYPE for some inline code
  can do so by defining the macro before their inline code and undef-ing
  it afterward so the macro does not escape.

- We no longer have rampant ODR violations due to including headers with
  different DEBUG_TYPE definitions. This may be mostly an academic
  violation today, but with modules these types of violations are easy
  to check for and potentially very relevant.

Where necessary to suppor headers with DEBUG_TYPE, I have moved the
definitions below the includes in this commit. I plan to move the rest
of the DEBUG_TYPE macros in LLVM in subsequent commits; this one is big
enough.

The comments in Debug.h, which were hilariously out of date already,
have been updated to reflect the recommended practice going forward.

llvm-svn: 206822
2014-04-21 22:55:11 +00:00
Yaron Keren
47e8a019e4 Patch by Ray Donnelly to print register names instead of numbers.
http://reviews.llvm.org/D3422

llvm-svn: 206683
2014-04-19 05:40:09 +00:00
David Blaikie
322880afda Add parens to appease GCC warning.
llvm-svn: 206678
2014-04-19 00:50:15 +00:00
David Blaikie
d6a2d14707 Compress debug sections only when beneficial.
Both ZLIB and the debug info compressed section header ("ZLIB" + the
size of the uncompressed data) take some constant overhead so in some
cases the compressed data is actually larger than the uncompressed data.
In these cases, just don't compress or rename the section at all.

llvm-svn: 206659
2014-04-18 21:52:26 +00:00