llvm-6502/test/MC/ELF
Peter Collingbourne c39f5dd0e2 MC: For variable symbols, maintain MCSymbol::Section as a cache.
Fixes PR19582.

Previously, when an asm assignment (.set or =) was created, we would look up
the section immediately in MCSymbol::setVariableValue. This caused symbols
to receive the wrong section if the RHS of the assignment had not been seen
yet. This had a knock-on effect in the object file emitters, causing them
to emit extra symbols, or to give symbols the wrong visibility or the wrong
section. For example, in the following asm:

.data
.Llocal:

.text
leaq .Llocal1(%rip), %rdi
.Llocal1 = .Llocal2
.Llocal2 = .Llocal

the first assignment would give .Llocal1 a null section, which would never get
fixed up by the second assignment. This would cause the ELF object file emitter
to consider .Llocal1 to be an undefined symbol and give it external linkage,
even though .Llocal1 should not have been emitted at all in the object file.

Or in the following asm:

alias_to_local = Ltmp0
Ltmp0:

the Mach-O object file emitter would give the alias_to_local symbol a n_type
of N_SECT and a n_sect of 0.  This is invalid under the Mach-O specification,
which requires N_SECT symbols to receive a non-zero section number if the
symbol is defined in a section in the object file.

https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachORuntime/#//apple_ref/c/tag/nlist

After this change we do not look up the section when the assignment is created,
but instead look it up on demand and store it in Section, which is treated
as a cache if the symbol is a variable symbol.

This change also fixes a bug in MCExpr::FindAssociatedSection. Previously,
if we saw a subtraction, we would return the first referenced section, even in
cases where we should have been returning the absolute pseudo-section. Now we
always return the absolute pseudo-section for expressions that subtract two
section-derived expressions. This isn't always correct (e.g. if one of the
sections ends up being laid out at an absolute address), but it's probably
the best we can do without more context.

This allows us to remove code in two places where we appear to have been
working around this bug, in MachObjectWriter::markAbsoluteVariableSymbols
and in X86AsmPrinter::EmitStartOfAsmFile.

Re-applies r233595 (aka D8586), which was reverted in r233898.

Differential Revision: http://reviews.llvm.org/D8798

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233995 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-03 01:46:11 +00:00
..
ARM Report error for non-zero data in .bss 2014-06-22 00:33:44 +00:00
abs.s Teach llvm-readobj to print human friendly description of reserved sections. 2014-03-24 05:00:34 +00:00
alias-reloc.s Teach llvm-readobj to print human friendly description of reserved sections. 2014-03-24 05:00:34 +00:00
alias.s MC: For variable symbols, maintain MCSymbol::Section as a cache. 2015-04-03 01:46:11 +00:00
align-bss.s
align-nops.s
align-size.s
align-text.s
align.s
bad-expr2.s Completely rewrite ELFObjectWriter::RecordRelocation. 2014-03-29 06:26:49 +00:00
bad-expr3.s Completely rewrite ELFObjectWriter::RecordRelocation. 2014-03-29 06:26:49 +00:00
bad-expr.s Forgot to add testcase for r198590 2014-01-21 20:39:11 +00:00
bad-relocation.s
bad-section.s
basic-elf-32.s Work around gold bug http://sourceware.org/PR16794. 2014-04-02 12:15:20 +00:00
basic-elf-64.s
bracket-exprs.s
bracket.s
bss-large.ll
bss.ll
call-abs.s
cfi-adjust-cfa-offset.s Reset the CFA offset at the start of every FDE. 2015-03-24 21:47:31 +00:00
cfi-advance-loc2.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-def-cfa-offset.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-def-cfa-register.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-def-cfa.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-escape.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-large-model.s Commit back the correct bits of r222760 (was r222538). 2014-11-27 17:13:56 +00:00
cfi-offset.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-reg.s
cfi-register.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-rel-offset2.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-rel-offset.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-remember.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-restore.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-same-value.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-sections.s Emit DWARF3 call frame information when DWARF3+ debug info is requested 2014-06-19 15:39:33 +00:00
cfi-signal-frame.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-undefined.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-version.ll DebugInfo: Move new hierarchy into place 2015-03-03 17:24:31 +00:00
cfi-window-save.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi-zero-addr-delta.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
cfi.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
comdat-dup-group-name.s
comdat-reloc.s
comdat.s Add back commits r219835 and a fixed version of r219829. 2014-10-17 01:48:58 +00:00
common2.s
common-error1.s Produce errors when an assignment expression would use a common symbol. 2015-01-19 17:30:24 +00:00
common-error2.s Produce errors when an assignment expression would use a common symbol. 2015-01-19 17:30:24 +00:00
common.s ELFObjectWriter: deduplicate suffices in strtab 2014-04-30 16:25:02 +00:00
comp-dir.s X86MCAsmInfoGNUCOFF: Set PointerSize as 8 for targeting x64. It caused DW_LNE_set_address was misemitted on x64. 2014-04-08 15:28:50 +00:00
compression.s Compress debug sections only when beneficial. 2014-04-18 21:52:26 +00:00
debug-line2.s
debug-line.s
debug-loc.s
diff2.s
diff.s
discriminator.s Support DWARF discriminators in object streamer. 2014-02-14 19:27:53 +00:00
dot-symbol-assignment.s Add support for assigning to . in AsmParser. 2014-02-17 20:48:32 +00:00
elf_directive_previous.s
elf_directive_section.s
empty-dwarf-lines.s
empty.s
entsize.ll [opaque pointer type] Add textual IR support for explicit type parameter to gep operator 2015-03-13 18:20:45 +00:00
entsize.s
fde.s
file-double.s ELFObjectWriter: deduplicate suffices in strtab 2014-04-30 16:25:02 +00:00
file.s Teach llvm-readobj to print human friendly description of reserved sections. 2014-03-24 05:00:34 +00:00
gen-dwarf.s Don't print labels that on ELF are never used. 2015-03-11 04:20:31 +00:00
global-offset.s
gnu-type-diagnostics.s MC: make ELF .type handling more GNU AS compatible 2014-06-08 00:34:34 +00:00
gnu-type.s MC: make ELF .type handling more GNU AS compatible 2014-06-08 00:34:34 +00:00
got.s
ident.s
ifunc-reloc.s Force emit a relocation for @gnu_indirect_function symbols so that the indirect 2014-01-08 18:50:32 +00:00
invalid-symver.s
lcomm.s ELFObjectWriter: deduplicate suffices in strtab 2014-04-30 16:25:02 +00:00
leb128.s
lit.local.cfg Reduce verbiage of lit.local.cfg files 2014-06-09 22:42:55 +00:00
local-reloc.s Fix broken CHECK lines 2014-02-16 07:31:05 +00:00
many-sections-2.s ELFObjectWriter: deduplicate suffices in strtab 2014-04-30 16:25:02 +00:00
many-sections.s Create .symtab_shndxr only when needed. 2014-03-25 23:44:25 +00:00
merge.s Completely rewrite ELFObjectWriter::RecordRelocation. 2014-03-29 06:26:49 +00:00
n_bytes.s
no-fixup.s
no-reloc.s Avoid revocations when possible. 2014-07-01 14:34:30 +00:00
nocompression.s llvm/test/MC/ELF/nocompression.s: Loosen an expression to match "llvm-mc.EXE". 2014-03-30 14:04:00 +00:00
noexec.s Revert llvm/test/MC/ELF/noexec.s in r227074, "Fix a problem where the AArch64 ELF assembler was failing with" 2015-01-26 09:30:29 +00:00
norelocation.s
offset.s Add an option for evaluating past symbols. 2014-04-28 20:53:11 +00:00
org.s
pic-diff.s ELFObjectWriter: deduplicate suffices in strtab 2014-04-30 16:25:02 +00:00
plt.s
pr9292.s ELFObjectWriter: deduplicate suffices in strtab 2014-04-30 16:25:02 +00:00
pr19430.s Revert "Reapply 222538 and update tests to explicitly request small code model and PIC:" 2014-11-27 17:13:51 +00:00
pr19582.s MC: For variable symbols, maintain MCSymbol::Section as a cache. 2015-04-03 01:46:11 +00:00
relax-all-flag.s
relax-arith.s
relax-crash.s
relax.s
reloc-same-name-section.s Add a test that would have found the bug in r219829. 2014-10-17 01:34:23 +00:00
relocation-386.s Reorganize the x86 ELF relocation selection logic. 2015-03-20 19:48:54 +00:00
relocation-pc.s Completely rewrite ELFObjectWriter::RecordRelocation. 2014-03-29 06:26:49 +00:00
relocation.s Reorganize the x86 ELF relocation selection logic. 2015-03-20 19:48:54 +00:00
rename.s
section-quoting.s
section-sym2.s Add back commits r219835 and a fixed version of r219829. 2014-10-17 01:48:58 +00:00
section-sym-err.s Add back commits r219835 and a fixed version of r219829. 2014-10-17 01:48:58 +00:00
section-sym.s Add back commits r219835 and a fixed version of r219829. 2014-10-17 01:48:58 +00:00
section-unique.s Add testcases I missed in r229541. 2015-02-17 20:50:39 +00:00
section.s
set.s ELFObjectWriter: deduplicate suffices in strtab 2014-04-30 16:25:02 +00:00
size.s Expand variables when evaluating absolute expressions. 2015-03-04 22:03:21 +00:00
sleb.s
strtab-suffix-opt.s ELFObjectWriter: deduplicate suffices in strtab 2014-04-30 16:25:02 +00:00
subsection.s
subtraction-error.s Produce an error instead of a crash in an expr we cannot represent. 2014-04-28 12:40:50 +00:00
symbol-names.s
symver-msvc.s [pr21886] Change MCJIT/ELF to support MSVC C++ mangled symbol. 2015-01-22 14:20:45 +00:00
symver.s Relax the test a bit. 2014-04-30 15:32:21 +00:00
tls-i386.s ELFObjectWriter: deduplicate suffices in strtab 2014-04-30 16:25:02 +00:00
tls.s ELFObjectWriter: deduplicate suffices in strtab 2014-04-30 16:25:02 +00:00
type-propagate.s Teach llvm-readobj to print human friendly description of reserved sections. 2014-03-24 05:00:34 +00:00
type.s Add STB_GNU_UNIQUE to the ELF writer. 2015-01-23 04:44:35 +00:00
uleb.s MC: Allow multiple comma-separated expressions on the .uleb128 directive. 2015-02-19 20:24:04 +00:00
undef2.s
undef.s Don't include an invalid symbol in the symbol table. 2014-04-28 13:39:57 +00:00
version.s
weak-diff.s Don't be over eager in evaluating a subtraction with a weak symbol. 2015-03-24 23:48:44 +00:00
weak-relocation.s
weak.s Teach llvm-readobj to print human friendly description of reserved sections. 2014-03-24 05:00:34 +00:00
weakref-plt.s
weakref-reloc.s Teach llvm-readobj to print human friendly description of reserved sections. 2014-03-24 05:00:34 +00:00
weakref.s ELFObjectWriter: deduplicate suffices in strtab 2014-04-30 16:25:02 +00:00
x86_64-reloc-sizetest.s
zero.s