Date: Sat, 19 Jan 2019 10:05:49 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r343179 - in vendor/lld/dist: . COFF Common ELF ELF/Arch MinGW docs include/lld/Common include/lld/Core lib/Driver lib/ReaderWriter/MachO test test/COFF test/COFF/Inputs test/ELF test/E... Message-ID: <201901191005.x0JA5n91041216@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Sat Jan 19 10:05:49 2019 New Revision: 343179 URL: https://svnweb.freebsd.org/changeset/base/343179 Log: Vendor import of lld trunk r351319 (just before the release_80 branch point): https://llvm.org/svn/llvm-project/lld/trunk@351319 Added: vendor/lld/dist/ELF/Arch/MSP430.cpp vendor/lld/dist/ELF/Arch/RISCV.cpp vendor/lld/dist/ELF/DWARF.cpp vendor/lld/dist/ELF/DWARF.h vendor/lld/dist/docs/missingkeyfunction.rst vendor/lld/dist/test/COFF/Inputs/associative-comdat-mingw-2.s vendor/lld/dist/test/COFF/Inputs/bad-block-size.pdb (contents, props changed) vendor/lld/dist/test/COFF/Inputs/comdat-jumptable2.s vendor/lld/dist/test/COFF/Inputs/common-replacement.s vendor/lld/dist/test/COFF/Inputs/crt-dyn-initializer-order_1.yaml vendor/lld/dist/test/COFF/Inputs/crt-dyn-initializer-order_2.yaml vendor/lld/dist/test/COFF/Inputs/empty.yaml vendor/lld/dist/test/COFF/Inputs/gnu-implib-data.s vendor/lld/dist/test/COFF/Inputs/gnu-implib-func.s vendor/lld/dist/test/COFF/Inputs/gnu-implib-head.s vendor/lld/dist/test/COFF/Inputs/gnu-implib-tail.s vendor/lld/dist/test/COFF/Inputs/gnu-weak.o (contents, props changed) vendor/lld/dist/test/COFF/Inputs/gnu-weak2.o (contents, props changed) vendor/lld/dist/test/COFF/Inputs/icf-safe.s vendor/lld/dist/test/COFF/Inputs/inline-weak.o (contents, props changed) vendor/lld/dist/test/COFF/Inputs/inline-weak2.o (contents, props changed) vendor/lld/dist/test/COFF/Inputs/pdb-type-server-missing-2.yaml vendor/lld/dist/test/COFF/Inputs/pdb-type-server-valid-signature.yaml vendor/lld/dist/test/COFF/Inputs/precomp-a.obj (contents, props changed) vendor/lld/dist/test/COFF/Inputs/precomp-b.obj (contents, props changed) vendor/lld/dist/test/COFF/Inputs/precomp-invalid.obj (contents, props changed) vendor/lld/dist/test/COFF/Inputs/precomp.obj (contents, props changed) vendor/lld/dist/test/COFF/arm-thumb-thunks-multipass.s vendor/lld/dist/test/COFF/arm-thumb-thunks.s vendor/lld/dist/test/COFF/arm64-delayimport.yaml vendor/lld/dist/test/COFF/arm64-localimport-align.s vendor/lld/dist/test/COFF/associative-comdat-mingw.s vendor/lld/dist/test/COFF/autoimport-arm-code.s vendor/lld/dist/test/COFF/autoimport-arm-data.s vendor/lld/dist/test/COFF/autoimport-arm64-code.s vendor/lld/dist/test/COFF/autoimport-arm64-data.s vendor/lld/dist/test/COFF/autoimport-gnu-implib.s vendor/lld/dist/test/COFF/autoimport-list-ptrs.s vendor/lld/dist/test/COFF/autoimport-refptr.s vendor/lld/dist/test/COFF/autoimport-x86.s vendor/lld/dist/test/COFF/broken-arm-reloc.yaml vendor/lld/dist/test/COFF/comdat-jumptable.s vendor/lld/dist/test/COFF/comdat-weak.test vendor/lld/dist/test/COFF/common-replacement.s vendor/lld/dist/test/COFF/could-not-open.test vendor/lld/dist/test/COFF/crt-dyn-initializer-order.test vendor/lld/dist/test/COFF/debug-fastlink.test vendor/lld/dist/test/COFF/directives.s vendor/lld/dist/test/COFF/duplicate-imp-func.s vendor/lld/dist/test/COFF/entry-inference-mingw.s vendor/lld/dist/test/COFF/entry-inference332.test vendor/lld/dist/test/COFF/entry-inference4.test vendor/lld/dist/test/COFF/force-multiple.test vendor/lld/dist/test/COFF/gfids-export.s vendor/lld/dist/test/COFF/gfids-relocations32.s vendor/lld/dist/test/COFF/gfids-relocations64.s vendor/lld/dist/test/COFF/gnu-weak.test vendor/lld/dist/test/COFF/header-size.s vendor/lld/dist/test/COFF/icf-safe.s vendor/lld/dist/test/COFF/ignore-many.test vendor/lld/dist/test/COFF/imports-gnu-autoexport.s vendor/lld/dist/test/COFF/imports-gnu-only.s vendor/lld/dist/test/COFF/imports-gnu.test vendor/lld/dist/test/COFF/invalid-debug.test vendor/lld/dist/test/COFF/libname-mingw.test vendor/lld/dist/test/COFF/line-error.yaml vendor/lld/dist/test/COFF/lto-cpu-string.ll vendor/lld/dist/test/COFF/no-idata.s vendor/lld/dist/test/COFF/pdb-debug-f.s vendor/lld/dist/test/COFF/pdb-framedata.yaml vendor/lld/dist/test/COFF/pdb-type-server-invalid-signature.yaml vendor/lld/dist/test/COFF/pdb-type-server-native-errors.yaml vendor/lld/dist/test/COFF/pdbaltpath.test vendor/lld/dist/test/COFF/precomp-link.test vendor/lld/dist/test/COFF/s_udt.s vendor/lld/dist/test/COFF/subsystem-inference-mingw.s vendor/lld/dist/test/COFF/subsystem-inference2.test vendor/lld/dist/test/COFF/subsystem-inference32.test vendor/lld/dist/test/ELF/Inputs/bad-reloc-target.test vendor/lld/dist/test/ELF/Inputs/copy-rel-tls.s vendor/lld/dist/test/ELF/Inputs/gdb-index-invalid-ranges.obj.s vendor/lld/dist/test/ELF/Inputs/gdb-index-multiple-cu-2.s vendor/lld/dist/test/ELF/Inputs/hexagon-shared.s vendor/lld/dist/test/ELF/Inputs/i386-linkonce.s vendor/lld/dist/test/ELF/Inputs/ppc64-bsymbolic-local-def.s vendor/lld/dist/test/ELF/Inputs/ppc64-no-split-stack.s vendor/lld/dist/test/ELF/Inputs/ppc64-tls-ie-le.s vendor/lld/dist/test/ELF/Inputs/ppc64le-quadword-ldst.o (contents, props changed) vendor/lld/dist/test/ELF/Inputs/wrap-with-archive.s vendor/lld/dist/test/ELF/Inputs/x86-64-split-stack-extra.s vendor/lld/dist/test/ELF/aarch64-combined-dynrel-ifunc.s vendor/lld/dist/test/ELF/aarch64-combined-dynrel.s vendor/lld/dist/test/ELF/aarch64-cortex-a53-843419-abs-mapsyms.s vendor/lld/dist/test/ELF/aarch64-cortex-a53-843419-large2.s vendor/lld/dist/test/ELF/aarch64-cortex-a53-843419-tlsrelax.s vendor/lld/dist/test/ELF/aarch64-gnu-ifunc-address.s vendor/lld/dist/test/ELF/aarch64-gnu-ifunc2.s vendor/lld/dist/test/ELF/aarch64-gnu-ifunc3.s vendor/lld/dist/test/ELF/archive-fetch.s vendor/lld/dist/test/ELF/arm-bl-v6-inrange.s vendor/lld/dist/test/ELF/arm-combined-dynrel-ifunc.s vendor/lld/dist/test/ELF/arm-extreme-range-pi-thunk.s vendor/lld/dist/test/ELF/arm-thumb-interwork-thunk-v5.s vendor/lld/dist/test/ELF/arm-thumb-thunk-v6m.s vendor/lld/dist/test/ELF/arm-thumb-undefined-weak-narrow.test vendor/lld/dist/test/ELF/arm-v4bx.test vendor/lld/dist/test/ELF/arm-v5-reloc-error.s vendor/lld/dist/test/ELF/as-needed-in-regular.s vendor/lld/dist/test/ELF/as-needed-not-in-regular.s vendor/lld/dist/test/ELF/bad-reloc-target.test vendor/lld/dist/test/ELF/cgprofile-obj.s vendor/lld/dist/test/ELF/cgprofile-shared-warn.s vendor/lld/dist/test/ELF/cgprofile-txt2.s vendor/lld/dist/test/ELF/copy-rel-tls.s vendor/lld/dist/test/ELF/debug-line-str.s vendor/lld/dist/test/ELF/debug-relocation-none.test vendor/lld/dist/test/ELF/dynamic-list-locals.s vendor/lld/dist/test/ELF/dynamic-list-unexpected-end.s vendor/lld/dist/test/ELF/emit-relocs-icf1.s vendor/lld/dist/test/ELF/emit-relocs-icf2.s vendor/lld/dist/test/ELF/empty-pack-dyn-relocs.s vendor/lld/dist/test/ELF/emulation-aarch64.s vendor/lld/dist/test/ELF/emulation-arm.s vendor/lld/dist/test/ELF/emulation-mips.s vendor/lld/dist/test/ELF/emulation-ppc.s vendor/lld/dist/test/ELF/emulation-x86.s vendor/lld/dist/test/ELF/gdb-index-dwarf5-low-high.s vendor/lld/dist/test/ELF/gdb-index-invalid-ranges.s vendor/lld/dist/test/ELF/gdb-index-multiple-cu-2.s vendor/lld/dist/test/ELF/gdb-index-multiple-cu.s vendor/lld/dist/test/ELF/gdb-index-no-debug.s vendor/lld/dist/test/ELF/gdb-index-rng-lists.s vendor/lld/dist/test/ELF/global-offset-table-position-redef-err.s vendor/lld/dist/test/ELF/gnu-ifunc-empty.s vendor/lld/dist/test/ELF/hexagon-eflag.s vendor/lld/dist/test/ELF/hexagon-shared.s vendor/lld/dist/test/ELF/i386-linkonce.s vendor/lld/dist/test/ELF/invalid/Inputs/undefined-local-symbol-in-dso.so (contents, props changed) vendor/lld/dist/test/ELF/invalid/comdat-broken.test vendor/lld/dist/test/ELF/invalid/ehframe-broken-relocation.test vendor/lld/dist/test/ELF/invalid/invalid-soname.test vendor/lld/dist/test/ELF/invalid/linkorder-invalid-sec.test vendor/lld/dist/test/ELF/invalid/linkorder-invalid-sec2.test vendor/lld/dist/test/ELF/invalid/merge-zero-size.test vendor/lld/dist/test/ELF/invalid/non-terminated-string.test vendor/lld/dist/test/ELF/invalid/sht-group-wrong-section.test vendor/lld/dist/test/ELF/invalid/sht-group.test vendor/lld/dist/test/ELF/invalid/undefined-local-symbol-in-dso.test vendor/lld/dist/test/ELF/lazy-arch-conflict.s vendor/lld/dist/test/ELF/linkerscript/Inputs/at6.s vendor/lld/dist/test/ELF/linkerscript/Inputs/at7.s vendor/lld/dist/test/ELF/linkerscript/Inputs/at8.s vendor/lld/dist/test/ELF/linkerscript/at6.test vendor/lld/dist/test/ELF/linkerscript/at7.test vendor/lld/dist/test/ELF/linkerscript/at8.test vendor/lld/dist/test/ELF/linkerscript/icf.s vendor/lld/dist/test/ELF/linkerscript/memory-include.test vendor/lld/dist/test/ELF/linkerscript/merge-nonalloc.s vendor/lld/dist/test/ELF/linkerscript/no-filename-spec.s vendor/lld/dist/test/ELF/linkerscript/output-section-include.test vendor/lld/dist/test/ELF/linkerscript/relocatable-discard.s vendor/lld/dist/test/ELF/linkerscript/section-include.test vendor/lld/dist/test/ELF/linkerscript/symbol-location.s vendor/lld/dist/test/ELF/linkerscript/target.s vendor/lld/dist/test/ELF/local-ver-preemptible.s vendor/lld/dist/test/ELF/lto/Inputs/libcall-archive.s vendor/lld/dist/test/ELF/lto/amdgcn.ll vendor/lld/dist/test/ELF/lto/emit-llvm.ll vendor/lld/dist/test/ELF/lto/ppc64le.ll vendor/lld/dist/test/ELF/lto/r600.ll vendor/lld/dist/test/ELF/mergeable-errors.s vendor/lld/dist/test/ELF/mips-traps.s vendor/lld/dist/test/ELF/msp430.s vendor/lld/dist/test/ELF/note-first-page.s vendor/lld/dist/test/ELF/pack-dyn-relocs-loop.s vendor/lld/dist/test/ELF/pack-dyn-relocs-tls-aarch64.s vendor/lld/dist/test/ELF/pack-dyn-relocs-tls-x86-64.s vendor/lld/dist/test/ELF/ppc64-bsymbolic-toc-restore.s vendor/lld/dist/test/ELF/ppc64-call-reach.s vendor/lld/dist/test/ELF/ppc64-dq.s vendor/lld/dist/test/ELF/ppc64-entry-point.s vendor/lld/dist/test/ELF/ppc64-error-missaligned-dq.s vendor/lld/dist/test/ELF/ppc64-error-missaligned-ds.s vendor/lld/dist/test/ELF/ppc64-got-off.s vendor/lld/dist/test/ELF/ppc64-long-branch.s vendor/lld/dist/test/ELF/ppc64-shared-long_branch.s vendor/lld/dist/test/ELF/ppc64-split-stack-adjust-fail.s vendor/lld/dist/test/ELF/ppc64-split-stack-adjust-overflow.s vendor/lld/dist/test/ELF/ppc64-split-stack-adjust-size-success.s vendor/lld/dist/test/ELF/ppc64-split-stack-prologue-adjust-success.s vendor/lld/dist/test/ELF/ppc64-tls-gd-le-small.s vendor/lld/dist/test/ELF/ppc64-tls-ie-le.s vendor/lld/dist/test/ELF/ppc64-toc-addis-nop-lqsq.s vendor/lld/dist/test/ELF/ppc64-toc-addis-nop.s vendor/lld/dist/test/ELF/ppc64-toc-restore-recursive-call.s vendor/lld/dist/test/ELF/ppc64-tocopt-option.s vendor/lld/dist/test/ELF/relocatable-rel-iplt.s vendor/lld/dist/test/ELF/relocation-before-merge-start.s vendor/lld/dist/test/ELF/riscv-branch.test vendor/lld/dist/test/ELF/riscv-call.test vendor/lld/dist/test/ELF/riscv-hi20-lo12.test vendor/lld/dist/test/ELF/riscv-jal-error.test vendor/lld/dist/test/ELF/riscv-jal.test vendor/lld/dist/test/ELF/riscv-pcrel-hilo.test vendor/lld/dist/test/ELF/static-error.s vendor/lld/dist/test/ELF/textrel.s vendor/lld/dist/test/ELF/wrap-entry.s vendor/lld/dist/test/ELF/wrap-plt.s vendor/lld/dist/test/ELF/wrap-with-archive.s vendor/lld/dist/test/ELF/x86-64-combined-dynrel.s vendor/lld/dist/test/ELF/x86-64-retpoline-znow-static-iplt.s vendor/lld/dist/test/ELF/x86-64-split-stack-prologue-adjust-shared.s vendor/lld/dist/test/wasm/Inputs/event-section1.ll vendor/lld/dist/test/wasm/Inputs/event-section2.ll vendor/lld/dist/test/wasm/archive-export.ll vendor/lld/dist/test/wasm/debug-removed-fn.ll vendor/lld/dist/test/wasm/event-section.ll vendor/lld/dist/test/wasm/lto/signature-mismatch.ll vendor/lld/dist/test/wasm/shared.ll vendor/lld/dist/test/wasm/strip-all.test vendor/lld/dist/wasm/InputEvent.h Deleted: vendor/lld/dist/ELF/GdbIndex.cpp vendor/lld/dist/ELF/GdbIndex.h vendor/lld/dist/include/lld/Core/TODO.txt vendor/lld/dist/test/COFF/Inputs/far-arm-thumb-abs.s vendor/lld/dist/test/COFF/Inputs/far-arm-thumb-abs20.s vendor/lld/dist/test/COFF/arm-thumb-branch-error.s vendor/lld/dist/test/COFF/msvclto-archive.ll vendor/lld/dist/test/COFF/msvclto-order.ll vendor/lld/dist/test/COFF/msvclto.ll vendor/lld/dist/test/ELF/emulation.s vendor/lld/dist/test/ELF/invalid/Inputs/shentsize-zero.elf vendor/lld/dist/test/ELF/invalid/Inputs/sht-group.elf vendor/lld/dist/test/ELF/invalid/sht-group.s vendor/lld/dist/test/ELF/linkerscript/ouputformat.s vendor/lld/dist/test/ELF/ppc64_entry_point.s Modified: vendor/lld/dist/COFF/Chunks.cpp vendor/lld/dist/COFF/Chunks.h vendor/lld/dist/COFF/Config.h vendor/lld/dist/COFF/DLL.cpp vendor/lld/dist/COFF/DLL.h vendor/lld/dist/COFF/Driver.cpp vendor/lld/dist/COFF/Driver.h vendor/lld/dist/COFF/DriverUtils.cpp vendor/lld/dist/COFF/ICF.cpp vendor/lld/dist/COFF/InputFiles.cpp vendor/lld/dist/COFF/InputFiles.h vendor/lld/dist/COFF/LTO.cpp vendor/lld/dist/COFF/MapFile.cpp vendor/lld/dist/COFF/MarkLive.cpp vendor/lld/dist/COFF/MinGW.cpp vendor/lld/dist/COFF/MinGW.h vendor/lld/dist/COFF/Options.td vendor/lld/dist/COFF/PDB.cpp vendor/lld/dist/COFF/PDB.h vendor/lld/dist/COFF/SymbolTable.cpp vendor/lld/dist/COFF/SymbolTable.h vendor/lld/dist/COFF/Symbols.cpp vendor/lld/dist/COFF/Symbols.h vendor/lld/dist/COFF/Writer.cpp vendor/lld/dist/COFF/Writer.h vendor/lld/dist/Common/Args.cpp vendor/lld/dist/Common/ErrorHandler.cpp vendor/lld/dist/Common/Strings.cpp vendor/lld/dist/Common/TargetOptionsCommandFlags.cpp vendor/lld/dist/ELF/AArch64ErrataFix.cpp vendor/lld/dist/ELF/Arch/AArch64.cpp vendor/lld/dist/ELF/Arch/AMDGPU.cpp vendor/lld/dist/ELF/Arch/ARM.cpp vendor/lld/dist/ELF/Arch/AVR.cpp vendor/lld/dist/ELF/Arch/Hexagon.cpp vendor/lld/dist/ELF/Arch/Mips.cpp vendor/lld/dist/ELF/Arch/PPC.cpp vendor/lld/dist/ELF/Arch/PPC64.cpp vendor/lld/dist/ELF/Arch/SPARCV9.cpp vendor/lld/dist/ELF/Arch/X86.cpp vendor/lld/dist/ELF/Arch/X86_64.cpp vendor/lld/dist/ELF/CMakeLists.txt vendor/lld/dist/ELF/CallGraphSort.cpp vendor/lld/dist/ELF/Config.h vendor/lld/dist/ELF/Driver.cpp vendor/lld/dist/ELF/Driver.h vendor/lld/dist/ELF/DriverUtils.cpp vendor/lld/dist/ELF/EhFrame.cpp vendor/lld/dist/ELF/ICF.cpp vendor/lld/dist/ELF/InputFiles.cpp vendor/lld/dist/ELF/InputFiles.h vendor/lld/dist/ELF/InputSection.cpp vendor/lld/dist/ELF/InputSection.h vendor/lld/dist/ELF/LTO.cpp vendor/lld/dist/ELF/LTO.h vendor/lld/dist/ELF/LinkerScript.cpp vendor/lld/dist/ELF/LinkerScript.h vendor/lld/dist/ELF/MapFile.cpp vendor/lld/dist/ELF/MarkLive.cpp vendor/lld/dist/ELF/Options.td vendor/lld/dist/ELF/OutputSections.cpp vendor/lld/dist/ELF/OutputSections.h vendor/lld/dist/ELF/Relocations.cpp vendor/lld/dist/ELF/Relocations.h vendor/lld/dist/ELF/ScriptLexer.cpp vendor/lld/dist/ELF/ScriptLexer.h vendor/lld/dist/ELF/ScriptParser.cpp vendor/lld/dist/ELF/SymbolTable.cpp vendor/lld/dist/ELF/SymbolTable.h vendor/lld/dist/ELF/Symbols.cpp vendor/lld/dist/ELF/Symbols.h vendor/lld/dist/ELF/SyntheticSections.cpp vendor/lld/dist/ELF/SyntheticSections.h vendor/lld/dist/ELF/Target.cpp vendor/lld/dist/ELF/Target.h vendor/lld/dist/ELF/Thunks.cpp vendor/lld/dist/ELF/Writer.cpp vendor/lld/dist/LICENSE.TXT vendor/lld/dist/MinGW/Driver.cpp vendor/lld/dist/MinGW/Options.td vendor/lld/dist/docs/NewLLD.rst vendor/lld/dist/docs/README.txt vendor/lld/dist/docs/Readers.rst vendor/lld/dist/docs/ReleaseNotes.rst vendor/lld/dist/docs/WebAssembly.rst vendor/lld/dist/docs/conf.py vendor/lld/dist/docs/index.rst vendor/lld/dist/docs/ld.lld.1 vendor/lld/dist/docs/open_projects.rst vendor/lld/dist/docs/windows_support.rst vendor/lld/dist/include/lld/Common/Args.h vendor/lld/dist/include/lld/Common/ErrorHandler.h vendor/lld/dist/include/lld/Common/LLVM.h vendor/lld/dist/include/lld/Common/Strings.h vendor/lld/dist/include/lld/Common/TargetOptionsCommandFlags.h vendor/lld/dist/include/lld/Common/Threads.h vendor/lld/dist/lib/Driver/DarwinLdDriver.cpp vendor/lld/dist/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp vendor/lld/dist/lib/ReaderWriter/MachO/MachOLinkingContext.cpp vendor/lld/dist/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h vendor/lld/dist/test/CMakeLists.txt vendor/lld/dist/test/COFF/Inputs/pdb-file-statics-a.yaml vendor/lld/dist/test/COFF/Inputs/pdb-file-statics-b.yaml vendor/lld/dist/test/COFF/Inputs/pdb-scopes-a.yaml vendor/lld/dist/test/COFF/Inputs/pdb-scopes-b.yaml vendor/lld/dist/test/COFF/Inputs/pdb-type-server-simple-a.yaml vendor/lld/dist/test/COFF/Inputs/pdb-type-server-simple-b.yaml vendor/lld/dist/test/COFF/arm-thumb-branch20-error.s vendor/lld/dist/test/COFF/arm64-relocs-imports.test vendor/lld/dist/test/COFF/baserel.test vendor/lld/dist/test/COFF/ctors_dtors_priority.s vendor/lld/dist/test/COFF/debug-reloc.s vendor/lld/dist/test/COFF/entry-inference.test vendor/lld/dist/test/COFF/entry-inference3.test vendor/lld/dist/test/COFF/export-all.s vendor/lld/dist/test/COFF/export.test vendor/lld/dist/test/COFF/guardcf-align.s vendor/lld/dist/test/COFF/invalid-debug-type.test vendor/lld/dist/test/COFF/lto-cache.ll vendor/lld/dist/test/COFF/lto-chkstk.ll vendor/lld/dist/test/COFF/pdb-global-hashes.test vendor/lld/dist/test/COFF/pdb-globals.test vendor/lld/dist/test/COFF/pdb-heapsite.yaml vendor/lld/dist/test/COFF/pdb-linker-module.test vendor/lld/dist/test/COFF/pdb-options.test vendor/lld/dist/test/COFF/pdb-procid-remapping.test vendor/lld/dist/test/COFF/pdb-relative-source-lines.test vendor/lld/dist/test/COFF/pdb-same-name.test vendor/lld/dist/test/COFF/pdb-symbol-types.yaml vendor/lld/dist/test/COFF/pdb-thunk.yaml vendor/lld/dist/test/COFF/pdb-type-server-missing.yaml vendor/lld/dist/test/COFF/pdb-type-server-simple.test vendor/lld/dist/test/COFF/pdb.test vendor/lld/dist/test/COFF/reloc-discarded.s vendor/lld/dist/test/COFF/rsds.test vendor/lld/dist/test/COFF/thinlto-archives.ll vendor/lld/dist/test/COFF/undefined-symbol-cv.s vendor/lld/dist/test/COFF/undefined-symbol.s vendor/lld/dist/test/COFF/wholearchive.s vendor/lld/dist/test/ELF/aarch64-abs16.s vendor/lld/dist/test/ELF/aarch64-abs32.s vendor/lld/dist/test/ELF/aarch64-call26-thunk.s vendor/lld/dist/test/ELF/aarch64-condb-reloc.s vendor/lld/dist/test/ELF/aarch64-copy.s vendor/lld/dist/test/ELF/aarch64-copy2.s vendor/lld/dist/test/ELF/aarch64-cortex-a53-843419-cli.s vendor/lld/dist/test/ELF/aarch64-cortex-a53-843419-large.s vendor/lld/dist/test/ELF/aarch64-cortex-a53-843419-recognize.s vendor/lld/dist/test/ELF/aarch64-data-relocs.s vendor/lld/dist/test/ELF/aarch64-gnu-ifunc-plt.s vendor/lld/dist/test/ELF/aarch64-gnu-ifunc.s vendor/lld/dist/test/ELF/aarch64-jump26-thunk.s vendor/lld/dist/test/ELF/aarch64-lo12-alignment.s vendor/lld/dist/test/ELF/aarch64-prel16.s vendor/lld/dist/test/ELF/aarch64-prel32.s vendor/lld/dist/test/ELF/aarch64-relocs.s vendor/lld/dist/test/ELF/aarch64-thunk-pi.s vendor/lld/dist/test/ELF/aarch64-thunk-section-location.s vendor/lld/dist/test/ELF/aarch64-tls-gdie.s vendor/lld/dist/test/ELF/aarch64-tls-gdle.s vendor/lld/dist/test/ELF/aarch64-tls-ie.s vendor/lld/dist/test/ELF/aarch64-tls-iele.s vendor/lld/dist/test/ELF/aarch64-tls-le.s vendor/lld/dist/test/ELF/aarch64-tlsld-ldst.s vendor/lld/dist/test/ELF/aarch64-tstbr14-reloc.s vendor/lld/dist/test/ELF/aarch64-undefined-weak.s vendor/lld/dist/test/ELF/amdgpu-elf-flags-err.s vendor/lld/dist/test/ELF/amdgpu-elf-flags.s vendor/lld/dist/test/ELF/amdgpu-kernels.s vendor/lld/dist/test/ELF/arm-bl-v6.s vendor/lld/dist/test/ELF/arm-blx-v4t.s vendor/lld/dist/test/ELF/arm-branch-rangethunk.s vendor/lld/dist/test/ELF/arm-branch-undef-weak-plt-thunk.s vendor/lld/dist/test/ELF/arm-long-thunk-converge.s vendor/lld/dist/test/ELF/arm-thumb-branch-rangethunk.s vendor/lld/dist/test/ELF/arm-thumb-branch.s vendor/lld/dist/test/ELF/arm-thumb-condbranch-thunk.s vendor/lld/dist/test/ELF/arm-thumb-interwork-shared.s vendor/lld/dist/test/ELF/arm-thumb-interwork-thunk-range.s vendor/lld/dist/test/ELF/arm-thumb-interwork-thunk.s vendor/lld/dist/test/ELF/arm-thumb-mix-range-thunk-os.s vendor/lld/dist/test/ELF/arm-thumb-plt-range-thunk-os.s vendor/lld/dist/test/ELF/arm-thumb-range-thunk-os.s vendor/lld/dist/test/ELF/arm-thumb-thunk-empty-pass.s vendor/lld/dist/test/ELF/arm-thumb-thunk-symbols.s vendor/lld/dist/test/ELF/arm-thunk-edgecase.s vendor/lld/dist/test/ELF/arm-thunk-largesection.s vendor/lld/dist/test/ELF/arm-thunk-linkerscript-dotexpr.s vendor/lld/dist/test/ELF/arm-thunk-linkerscript-large.s vendor/lld/dist/test/ELF/arm-thunk-linkerscript-orphan.s vendor/lld/dist/test/ELF/arm-thunk-linkerscript-sort.s vendor/lld/dist/test/ELF/arm-thunk-linkerscript.s vendor/lld/dist/test/ELF/arm-thunk-multipass.s vendor/lld/dist/test/ELF/arm-thunk-nosuitable.s vendor/lld/dist/test/ELF/arm-thunk-re-add.s vendor/lld/dist/test/ELF/arm-thunk-section-too-large.s vendor/lld/dist/test/ELF/arm-tls-le32.s vendor/lld/dist/test/ELF/arm-tls-norelax-ie-le.s vendor/lld/dist/test/ELF/as-needed-weak.s vendor/lld/dist/test/ELF/basic-aarch64.s vendor/lld/dist/test/ELF/basic-ppc64.s vendor/lld/dist/test/ELF/basic32.s vendor/lld/dist/test/ELF/basic64be.s vendor/lld/dist/test/ELF/bsymbolic-undef.s vendor/lld/dist/test/ELF/common-gc2.s vendor/lld/dist/test/ELF/compressed-debug-input-err.s vendor/lld/dist/test/ELF/conflict.s vendor/lld/dist/test/ELF/defsym.s vendor/lld/dist/test/ELF/dont-export-hidden.s vendor/lld/dist/test/ELF/driver-access.test vendor/lld/dist/test/ELF/driver.test vendor/lld/dist/test/ELF/dt_flags.s vendor/lld/dist/test/ELF/dynamic-list-preempt.s vendor/lld/dist/test/ELF/dynamic-list-wildcard.s vendor/lld/dist/test/ELF/dynamic-list.s vendor/lld/dist/test/ELF/dynamic-reloc.s vendor/lld/dist/test/ELF/dynsym-no-rosegment.s vendor/lld/dist/test/ELF/dynsym-pie.s vendor/lld/dist/test/ELF/edata-etext.s vendor/lld/dist/test/ELF/empty-ver.s vendor/lld/dist/test/ELF/empty-ver2.s vendor/lld/dist/test/ELF/execute-only-mixed-data.s vendor/lld/dist/test/ELF/format-binary.test vendor/lld/dist/test/ELF/gc-sections-implicit-addend.s vendor/lld/dist/test/ELF/gc-sections-linker-defined-symbol.s vendor/lld/dist/test/ELF/gdb-index-base-addr.s vendor/lld/dist/test/ELF/gdb-index-ranges.s vendor/lld/dist/test/ELF/gdb-index.s vendor/lld/dist/test/ELF/gnu-hash-table-copy.s vendor/lld/dist/test/ELF/gnu-hash-table-rwsegment.s vendor/lld/dist/test/ELF/gnu-hash-table.s vendor/lld/dist/test/ELF/gnu-ifunc-i386.s vendor/lld/dist/test/ELF/gnu-ifunc-plt-i386.s vendor/lld/dist/test/ELF/gnu-ifunc-plt.s vendor/lld/dist/test/ELF/gnu-ifunc-relative.s vendor/lld/dist/test/ELF/gnu-ifunc-shared.s vendor/lld/dist/test/ELF/gnu-ifunc.s vendor/lld/dist/test/ELF/gnu-unique.s vendor/lld/dist/test/ELF/got-i386.s vendor/lld/dist/test/ELF/got32-i386-pie-rw.s vendor/lld/dist/test/ELF/got32-i386.s vendor/lld/dist/test/ELF/got32x-i386.s vendor/lld/dist/test/ELF/hexagon.s vendor/lld/dist/test/ELF/i386-pc8-pc16-addend.s vendor/lld/dist/test/ELF/i386-retpoline-nopic.s vendor/lld/dist/test/ELF/icf13.s vendor/lld/dist/test/ELF/icf15.s vendor/lld/dist/test/ELF/icf16.s vendor/lld/dist/test/ELF/icf17.s vendor/lld/dist/test/ELF/image-base.s vendor/lld/dist/test/ELF/incompatible-ar-first.s vendor/lld/dist/test/ELF/incompatible.s vendor/lld/dist/test/ELF/invalid-linkerscript.test vendor/lld/dist/test/ELF/invalid/merge-invalid-size.s vendor/lld/dist/test/ELF/linkerscript/align-r.test vendor/lld/dist/test/ELF/linkerscript/align4.test vendor/lld/dist/test/ELF/linkerscript/discard-section-err.s vendor/lld/dist/test/ELF/linkerscript/filename-spec.s vendor/lld/dist/test/ELF/linkerscript/info-section-type.s vendor/lld/dist/test/ELF/linkerscript/lazy-symbols.test vendor/lld/dist/test/ELF/linkerscript/map-file.test vendor/lld/dist/test/ELF/linkerscript/map-file2.test vendor/lld/dist/test/ELF/linkerscript/non-alloc-segment.s vendor/lld/dist/test/ELF/linkerscript/non-alloc.s vendor/lld/dist/test/ELF/linkerscript/orphan-discard.s vendor/lld/dist/test/ELF/linkerscript/orphan-phdrs.s vendor/lld/dist/test/ELF/linkerscript/output-too-large.s vendor/lld/dist/test/ELF/linkerscript/phdrs.s vendor/lld/dist/test/ELF/linkerscript/provide-shared2.s vendor/lld/dist/test/ELF/linkerscript/sections-va-overflow.test vendor/lld/dist/test/ELF/linkerscript/segment-none.s vendor/lld/dist/test/ELF/linkerscript/sizeof.s vendor/lld/dist/test/ELF/linkerscript/sizeofheaders.s vendor/lld/dist/test/ELF/linkerscript/sort-init.s vendor/lld/dist/test/ELF/linkerscript/sort-non-script.s vendor/lld/dist/test/ELF/linkerscript/symbol-assignexpr.s vendor/lld/dist/test/ELF/linkerscript/symbol-memoryexpr.s vendor/lld/dist/test/ELF/linkerscript/unused-synthetic.s vendor/lld/dist/test/ELF/linkerscript/version-script.s vendor/lld/dist/test/ELF/local-dynamic.s vendor/lld/dist/test/ELF/lto-plugin-ignore.s vendor/lld/dist/test/ELF/lto/cache.ll vendor/lld/dist/test/ELF/lto/data-ordering-lto.s vendor/lld/dist/test/ELF/lto/defsym.ll vendor/lld/dist/test/ELF/lto/dynamic-list.ll vendor/lld/dist/test/ELF/lto/libcall-archive.ll vendor/lld/dist/test/ELF/lto/ltopasses-custom.ll vendor/lld/dist/test/ELF/lto/opt-remarks.ll vendor/lld/dist/test/ELF/lto/relocatable.ll vendor/lld/dist/test/ELF/lto/section-name.ll vendor/lld/dist/test/ELF/lto/shlib-undefined.ll vendor/lld/dist/test/ELF/lto/symbol-ordering-lto.s vendor/lld/dist/test/ELF/lto/thinlto-obj-path.ll vendor/lld/dist/test/ELF/lto/thinlto-object-suffix-replace.ll vendor/lld/dist/test/ELF/lto/undefined-puts.ll vendor/lld/dist/test/ELF/lto/version-script.ll vendor/lld/dist/test/ELF/lto/wrap-2.ll vendor/lld/dist/test/ELF/map-file-i686.s vendor/lld/dist/test/ELF/merge-string-error.s vendor/lld/dist/test/ELF/mips-32.s vendor/lld/dist/test/ELF/mips-64.s vendor/lld/dist/test/ELF/mips-dynamic.s vendor/lld/dist/test/ELF/mips-dynsym-sort.s vendor/lld/dist/test/ELF/mips-gnu-hash.s vendor/lld/dist/test/ELF/mips-got-and-copy.s vendor/lld/dist/test/ELF/mips-got-extsym.s vendor/lld/dist/test/ELF/mips-got-relocs.s vendor/lld/dist/test/ELF/mips-got16-relocatable.s vendor/lld/dist/test/ELF/mips-got16.s vendor/lld/dist/test/ELF/mips-hilo.s vendor/lld/dist/test/ELF/mips-mgot.s vendor/lld/dist/test/ELF/mips-micro-jal.s vendor/lld/dist/test/ELF/mips-micro-plt.s vendor/lld/dist/test/ELF/mips-npic-call-pic-os.s vendor/lld/dist/test/ELF/mips-npic-call-pic-script.s vendor/lld/dist/test/ELF/mips-npic-call-pic.s vendor/lld/dist/test/ELF/mips-sto-plt.s vendor/lld/dist/test/ELF/mips-tls-64.s vendor/lld/dist/test/ELF/mips-tls-hilo.s vendor/lld/dist/test/ELF/mips-tls-static-64.s vendor/lld/dist/test/ELF/mips-tls-static.s vendor/lld/dist/test/ELF/mips-tls.s vendor/lld/dist/test/ELF/no-obj.s vendor/lld/dist/test/ELF/oformat-binary.s vendor/lld/dist/test/ELF/plt-aarch64.s vendor/lld/dist/test/ELF/plt-i686.s vendor/lld/dist/test/ELF/plt.s vendor/lld/dist/test/ELF/ppc-relocs.s vendor/lld/dist/test/ELF/ppc64-dtprel.s vendor/lld/dist/test/ELF/ppc64-func-entry-points.s vendor/lld/dist/test/ELF/ppc64-gd-to-ie.s vendor/lld/dist/test/ELF/ppc64-general-dynamic-tls.s vendor/lld/dist/test/ELF/ppc64-got-indirect.s vendor/lld/dist/test/ELF/ppc64-initial-exec-tls.s vendor/lld/dist/test/ELF/ppc64-local-dynamic.s vendor/lld/dist/test/ELF/ppc64-local-exec-tls.s vendor/lld/dist/test/ELF/ppc64-rel-so-local-calls.s vendor/lld/dist/test/ELF/ppc64-relocs.s vendor/lld/dist/test/ELF/ppc64-tls-gd-le.s vendor/lld/dist/test/ELF/ppc64-tls-ld-le.s vendor/lld/dist/test/ELF/ppc64-toc-rel.s vendor/lld/dist/test/ELF/ppc64-toc-restore.s vendor/lld/dist/test/ELF/pr34660.s vendor/lld/dist/test/ELF/progname.s vendor/lld/dist/test/ELF/protected-shared.s vendor/lld/dist/test/ELF/push-state.s vendor/lld/dist/test/ELF/relative-dynamic-reloc-ppc64.s vendor/lld/dist/test/ELF/relative-dynamic-reloc.s vendor/lld/dist/test/ELF/relocatable-bss.s vendor/lld/dist/test/ELF/relocatable-comdat-multiple.s vendor/lld/dist/test/ELF/relocatable-comdat.s vendor/lld/dist/test/ELF/relocatable-comdat2.s vendor/lld/dist/test/ELF/relocatable-compressed-input.s vendor/lld/dist/test/ELF/relocatable-many-sections.s vendor/lld/dist/test/ELF/relocatable.s vendor/lld/dist/test/ELF/relocation-b-aarch64.test vendor/lld/dist/test/ELF/relocation-common.s vendor/lld/dist/test/ELF/relocation-copy-i686.s vendor/lld/dist/test/ELF/relocation-i686.s vendor/lld/dist/test/ELF/relocation-past-merge-end.s vendor/lld/dist/test/ELF/relocation-size-shared.s vendor/lld/dist/test/ELF/relocation-size.s vendor/lld/dist/test/ELF/reproduce-backslash.s vendor/lld/dist/test/ELF/retain-symbols-file.s vendor/lld/dist/test/ELF/shared.s vendor/lld/dist/test/ELF/sort-norosegment.s vendor/lld/dist/test/ELF/static-with-export-dynamic.s vendor/lld/dist/test/ELF/strip-debug.s vendor/lld/dist/test/ELF/symbol-ordering-file-warnings.s vendor/lld/dist/test/ELF/tls-i686.s vendor/lld/dist/test/ELF/tls-in-archive.s vendor/lld/dist/test/ELF/tls-opt-gdiele-i686.s vendor/lld/dist/test/ELF/tls-opt-i686.s vendor/lld/dist/test/ELF/tls-opt-iele-i686-nopic.s vendor/lld/dist/test/ELF/tls-static.s vendor/lld/dist/test/ELF/tls-weak-undef.s vendor/lld/dist/test/ELF/trace-ar.s vendor/lld/dist/test/ELF/trace-symbols.s vendor/lld/dist/test/ELF/undef-broken-debug.test vendor/lld/dist/test/ELF/undef-version-script.s vendor/lld/dist/test/ELF/undef-with-plt-addr-i686.s vendor/lld/dist/test/ELF/undef.s vendor/lld/dist/test/ELF/verdef-defaultver.s vendor/lld/dist/test/ELF/verdef.s vendor/lld/dist/test/ELF/verneed.s vendor/lld/dist/test/ELF/version-exclude-libs.s vendor/lld/dist/test/ELF/version-script-complex-wildcards.s vendor/lld/dist/test/ELF/version-script-extern-undefined.s vendor/lld/dist/test/ELF/version-script-extern-wildcards.s vendor/lld/dist/test/ELF/version-script-extern.s vendor/lld/dist/test/ELF/version-script-extern2.s vendor/lld/dist/test/ELF/version-script-hide-so-symbol.s vendor/lld/dist/test/ELF/version-script-locals-extern.s vendor/lld/dist/test/ELF/version-script-symver2.s vendor/lld/dist/test/ELF/version-script-weak.s vendor/lld/dist/test/ELF/version-script.s vendor/lld/dist/test/ELF/version-wildcard.test vendor/lld/dist/test/ELF/visibility.s vendor/lld/dist/test/ELF/weak-undef-export.s vendor/lld/dist/test/ELF/weak-undef.s vendor/lld/dist/test/ELF/wrap-no-real.s vendor/lld/dist/test/ELF/wrap.s vendor/lld/dist/test/ELF/x86-64-reloc-error2.s vendor/lld/dist/test/ELF/x86-64-reloc-gotoff64.s vendor/lld/dist/test/ELF/x86-64-reloc-gotpc64.s vendor/lld/dist/test/ELF/x86-64-reloc-range-debug-loc.s vendor/lld/dist/test/ELF/x86-64-reloc-range.s vendor/lld/dist/test/ELF/x86-64-split-stack-prologue-adjust-fail.s vendor/lld/dist/test/ELF/x86-64-split-stack-prologue-adjust-silent.s vendor/lld/dist/test/ELF/x86-64-split-stack-prologue-adjust-success.s vendor/lld/dist/test/ELF/znotext-plt-relocations-protected.s vendor/lld/dist/test/ELF/zstack-size.s vendor/lld/dist/test/MinGW/driver.test vendor/lld/dist/test/lit.cfg.py vendor/lld/dist/test/lit.site.cfg.py.in vendor/lld/dist/test/mach-o/cstring-sections.yaml vendor/lld/dist/test/mach-o/dependency_info.yaml vendor/lld/dist/test/mach-o/parse-data-relocs-x86_64.yaml vendor/lld/dist/test/mach-o/parse-data.yaml vendor/lld/dist/test/mach-o/sectcreate.yaml vendor/lld/dist/test/wasm/Inputs/globals.yaml vendor/lld/dist/test/wasm/Inputs/undefined-globals.yaml vendor/lld/dist/test/wasm/alias.ll vendor/lld/dist/test/wasm/archive.ll vendor/lld/dist/test/wasm/call-indirect.ll vendor/lld/dist/test/wasm/comdats.ll vendor/lld/dist/test/wasm/compress-relocs.ll vendor/lld/dist/test/wasm/cxx-mangling.ll vendor/lld/dist/test/wasm/data-layout.ll vendor/lld/dist/test/wasm/data-segment-merging.ll vendor/lld/dist/test/wasm/debuginfo.test vendor/lld/dist/test/wasm/demangle.ll vendor/lld/dist/test/wasm/export-all.ll vendor/lld/dist/test/wasm/export-table.test vendor/lld/dist/test/wasm/export.ll vendor/lld/dist/test/wasm/import-memory.test vendor/lld/dist/test/wasm/import-table.test vendor/lld/dist/test/wasm/load-undefined.test vendor/lld/dist/test/wasm/local-symbols.ll vendor/lld/dist/test/wasm/locals-duplicate.test vendor/lld/dist/test/wasm/lto/archive.ll vendor/lld/dist/test/wasm/lto/cache.ll vendor/lld/dist/test/wasm/lto/export.ll vendor/lld/dist/test/wasm/many-functions.ll vendor/lld/dist/test/wasm/relocatable.ll vendor/lld/dist/test/wasm/signature-mismatch-weak.ll vendor/lld/dist/test/wasm/signature-mismatch.ll vendor/lld/dist/test/wasm/stack-pointer.ll vendor/lld/dist/test/wasm/strip-debug.test vendor/lld/dist/test/wasm/undefined-entry.test vendor/lld/dist/test/wasm/undefined-weak-call.ll vendor/lld/dist/test/wasm/undefined.ll vendor/lld/dist/test/wasm/visibility-hidden.ll vendor/lld/dist/test/wasm/weak-alias-overide.ll vendor/lld/dist/test/wasm/weak-alias.ll vendor/lld/dist/test/wasm/weak-symbols.ll vendor/lld/dist/test/wasm/weak-undefined.ll vendor/lld/dist/tools/lld/lld.cpp vendor/lld/dist/wasm/Config.h vendor/lld/dist/wasm/Driver.cpp vendor/lld/dist/wasm/InputChunks.cpp vendor/lld/dist/wasm/InputChunks.h vendor/lld/dist/wasm/InputFiles.cpp vendor/lld/dist/wasm/InputFiles.h vendor/lld/dist/wasm/InputGlobal.h vendor/lld/dist/wasm/LTO.cpp vendor/lld/dist/wasm/MarkLive.cpp vendor/lld/dist/wasm/Options.td vendor/lld/dist/wasm/OutputSections.cpp vendor/lld/dist/wasm/OutputSections.h vendor/lld/dist/wasm/OutputSegment.h vendor/lld/dist/wasm/SymbolTable.cpp vendor/lld/dist/wasm/SymbolTable.h vendor/lld/dist/wasm/Symbols.cpp vendor/lld/dist/wasm/Symbols.h vendor/lld/dist/wasm/Writer.cpp vendor/lld/dist/wasm/WriterUtils.cpp vendor/lld/dist/wasm/WriterUtils.h Modified: vendor/lld/dist/COFF/Chunks.cpp ============================================================================== --- vendor/lld/dist/COFF/Chunks.cpp Sat Jan 19 10:05:41 2019 (r343178) +++ vendor/lld/dist/COFF/Chunks.cpp Sat Jan 19 10:05:49 2019 (r343179) @@ -11,6 +11,7 @@ #include "InputFiles.h" #include "Symbols.h" #include "Writer.h" +#include "SymbolTable.h" #include "lld/Common/ErrorHandler.h" #include "llvm/ADT/Twine.h" #include "llvm/BinaryFormat/COFF.h" @@ -44,6 +45,22 @@ SectionChunk::SectionChunk(ObjFile *F, const coff_sect Live = !Config->DoGC || !isCOMDAT(); } +// Initialize the RelocTargets vector, to allow redirecting certain relocations +// to a thunk instead of the actual symbol the relocation's symbol table index +// indicates. +void SectionChunk::readRelocTargets() { + assert(RelocTargets.empty()); + RelocTargets.reserve(Relocs.size()); + for (const coff_relocation &Rel : Relocs) + RelocTargets.push_back(File->getSymbol(Rel.SymbolTableIndex)); +} + +// Reset RelocTargets to their original targets before thunks were added. +void SectionChunk::resetRelocTargets() { + for (size_t I = 0, E = Relocs.size(); I < E; ++I) + RelocTargets[I] = File->getSymbol(Relocs[I].SymbolTableIndex); +} + static void add16(uint8_t *P, int16_t V) { write16le(P, read16le(P) + V); } static void add32(uint8_t *P, int32_t V) { write32le(P, read32le(P) + V); } static void add64(uint8_t *P, int64_t V) { write64le(P, read64le(P) + V); } @@ -58,7 +75,8 @@ static bool checkSecRel(const SectionChunk *Sec, Outpu return true; if (Sec->isCodeView()) return false; - fatal("SECREL relocation cannot be applied to absolute symbols"); + error("SECREL relocation cannot be applied to absolute symbols"); + return false; } static void applySecRel(const SectionChunk *Sec, uint8_t *Off, @@ -98,7 +116,7 @@ void SectionChunk::applyRelX64(uint8_t *Off, uint16_t case IMAGE_REL_AMD64_SECTION: applySecIdx(Off, OS); break; case IMAGE_REL_AMD64_SECREL: applySecRel(this, Off, OS, S); break; default: - fatal("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + + error("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + toString(File)); } } @@ -113,7 +131,7 @@ void SectionChunk::applyRelX86(uint8_t *Off, uint16_t case IMAGE_REL_I386_SECTION: applySecIdx(Off, OS); break; case IMAGE_REL_I386_SECREL: applySecRel(this, Off, OS, S); break; default: - fatal("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + + error("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + toString(File)); } } @@ -123,16 +141,22 @@ static void applyMOV(uint8_t *Off, uint16_t V) { write16le(Off + 2, (read16le(Off + 2) & 0x8f00) | ((V & 0x700) << 4) | (V & 0xff)); } -static uint16_t readMOV(uint8_t *Off) { +static uint16_t readMOV(uint8_t *Off, bool MOVT) { uint16_t Op1 = read16le(Off); + if ((Op1 & 0xfbf0) != (MOVT ? 0xf2c0 : 0xf240)) + error("unexpected instruction in " + Twine(MOVT ? "MOVT" : "MOVW") + + " instruction in MOV32T relocation"); uint16_t Op2 = read16le(Off + 2); + if ((Op2 & 0x8000) != 0) + error("unexpected instruction in " + Twine(MOVT ? "MOVT" : "MOVW") + + " instruction in MOV32T relocation"); return (Op2 & 0x00ff) | ((Op2 >> 4) & 0x0700) | ((Op1 << 1) & 0x0800) | ((Op1 & 0x000f) << 12); } void applyMOV32T(uint8_t *Off, uint32_t V) { - uint16_t ImmW = readMOV(Off); // read MOVW operand - uint16_t ImmT = readMOV(Off + 4); // read MOVT operand + uint16_t ImmW = readMOV(Off, false); // read MOVW operand + uint16_t ImmT = readMOV(Off + 4, true); // read MOVT operand uint32_t Imm = ImmW | (ImmT << 16); V += Imm; // add the immediate offset applyMOV(Off, V); // set MOVW operand @@ -141,7 +165,7 @@ void applyMOV32T(uint8_t *Off, uint32_t V) { static void applyBranch20T(uint8_t *Off, int32_t V) { if (!isInt<21>(V)) - fatal("relocation out of range"); + error("relocation out of range"); uint32_t S = V < 0 ? 1 : 0; uint32_t J1 = (V >> 19) & 1; uint32_t J2 = (V >> 18) & 1; @@ -151,7 +175,7 @@ static void applyBranch20T(uint8_t *Off, int32_t V) { void applyBranch24T(uint8_t *Off, int32_t V) { if (!isInt<25>(V)) - fatal("relocation out of range"); + error("relocation out of range"); uint32_t S = V < 0 ? 1 : 0; uint32_t J1 = ((~V >> 23) & 1) ^ S; uint32_t J2 = ((~V >> 22) & 1) ^ S; @@ -176,7 +200,7 @@ void SectionChunk::applyRelARM(uint8_t *Off, uint16_t case IMAGE_REL_ARM_SECTION: applySecIdx(Off, OS); break; case IMAGE_REL_ARM_SECREL: applySecRel(this, Off, OS, S); break; default: - fatal("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + + error("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + toString(File)); } } @@ -184,7 +208,7 @@ void SectionChunk::applyRelARM(uint8_t *Off, uint16_t // Interpret the existing immediate value as a byte offset to the // target symbol, then update the instruction with the immediate as // the page offset from the current instruction to the target. -static void applyArm64Addr(uint8_t *Off, uint64_t S, uint64_t P, int Shift) { +void applyArm64Addr(uint8_t *Off, uint64_t S, uint64_t P, int Shift) { uint32_t Orig = read32le(Off); uint64_t Imm = ((Orig >> 29) & 0x3) | ((Orig >> 3) & 0x1FFFFC); S += Imm; @@ -198,7 +222,7 @@ static void applyArm64Addr(uint8_t *Off, uint64_t S, u // Update the immediate field in a AARCH64 ldr, str, and add instruction. // Optionally limit the range of the written immediate by one or more bits // (RangeLimit). -static void applyArm64Imm(uint8_t *Off, uint64_t Imm, uint32_t RangeLimit) { +void applyArm64Imm(uint8_t *Off, uint64_t Imm, uint32_t RangeLimit) { uint32_t Orig = read32le(Off); Imm += (Orig >> 10) & 0xFFF; Orig &= ~(0xFFF << 10); @@ -221,7 +245,7 @@ static void applyArm64Ldr(uint8_t *Off, uint64_t Imm) if ((Orig & 0x4800000) == 0x4800000) Size += 4; if ((Imm & ((1 << Size) - 1)) != 0) - fatal("misaligned ldr/str offset"); + error("misaligned ldr/str offset"); applyArm64Imm(Off, Imm >> Size, Size); } @@ -250,21 +274,21 @@ static void applySecRelLdr(const SectionChunk *Sec, ui applyArm64Ldr(Off, (S - OS->getRVA()) & 0xfff); } -static void applyArm64Branch26(uint8_t *Off, int64_t V) { +void applyArm64Branch26(uint8_t *Off, int64_t V) { if (!isInt<28>(V)) - fatal("relocation out of range"); + error("relocation out of range"); or32(Off, (V & 0x0FFFFFFC) >> 2); } static void applyArm64Branch19(uint8_t *Off, int64_t V) { if (!isInt<21>(V)) - fatal("relocation out of range"); + error("relocation out of range"); or32(Off, (V & 0x001FFFFC) << 3); } static void applyArm64Branch14(uint8_t *Off, int64_t V) { if (!isInt<16>(V)) - fatal("relocation out of range"); + error("relocation out of range"); or32(Off, (V & 0x0000FFFC) << 3); } @@ -287,11 +311,37 @@ void SectionChunk::applyRelARM64(uint8_t *Off, uint16_ case IMAGE_REL_ARM64_SECREL_LOW12L: applySecRelLdr(this, Off, OS, S); break; case IMAGE_REL_ARM64_SECTION: applySecIdx(Off, OS); break; default: - fatal("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + + error("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + toString(File)); } } +static void maybeReportRelocationToDiscarded(const SectionChunk *FromChunk, + Defined *Sym, + const coff_relocation &Rel) { + // Don't report these errors when the relocation comes from a debug info + // section or in mingw mode. MinGW mode object files (built by GCC) can + // have leftover sections with relocations against discarded comdat + // sections. Such sections are left as is, with relocations untouched. + if (FromChunk->isCodeView() || FromChunk->isDWARF() || Config->MinGW) + return; + + // Get the name of the symbol. If it's null, it was discarded early, so we + // have to go back to the object file. + ObjFile *File = FromChunk->File; + StringRef Name; + if (Sym) { + Name = Sym->getName(); + } else { + COFFSymbolRef COFFSym = + check(File->getCOFFObj()->getSymbol(Rel.SymbolTableIndex)); + File->getCOFFObj()->getSymbolName(COFFSym, Name); + } + + error("relocation against symbol in discarded section: " + Name + + getSymbolLocations(File, Rel.SymbolTableIndex)); +} + void SectionChunk::writeTo(uint8_t *Buf) const { if (!hasData()) return; @@ -302,46 +352,40 @@ void SectionChunk::writeTo(uint8_t *Buf) const { // Apply relocations. size_t InputSize = getSize(); - for (const coff_relocation &Rel : Relocs) { + for (size_t I = 0, E = Relocs.size(); I < E; I++) { + const coff_relocation &Rel = Relocs[I]; + // Check for an invalid relocation offset. This check isn't perfect, because // we don't have the relocation size, which is only known after checking the // machine and relocation type. As a result, a relocation may overwrite the // beginning of the following input section. - if (Rel.VirtualAddress >= InputSize) - fatal("relocation points beyond the end of its parent section"); + if (Rel.VirtualAddress >= InputSize) { + error("relocation points beyond the end of its parent section"); + continue; + } uint8_t *Off = Buf + OutputSectionOff + Rel.VirtualAddress; + // Use the potentially remapped Symbol instead of the one that the + // relocation points to. + auto *Sym = dyn_cast_or_null<Defined>(RelocTargets[I]); + // Get the output section of the symbol for this relocation. The output // section is needed to compute SECREL and SECTION relocations used in debug // info. - auto *Sym = - dyn_cast_or_null<Defined>(File->getSymbol(Rel.SymbolTableIndex)); - if (!Sym) { - if (isCodeView() || isDWARF()) - continue; - // Symbols in early discarded sections are represented using null pointers, - // so we need to retrieve the name from the object file. - COFFSymbolRef Sym = - check(File->getCOFFObj()->getSymbol(Rel.SymbolTableIndex)); - StringRef Name; - File->getCOFFObj()->getSymbolName(Sym, Name); - fatal("relocation against symbol in discarded section: " + Name); - } - Chunk *C = Sym->getChunk(); + Chunk *C = Sym ? Sym->getChunk() : nullptr; OutputSection *OS = C ? C->getOutputSection() : nullptr; - // Only absolute and __ImageBase symbols lack an output section. For any - // other symbol, this indicates that the chunk was discarded. Normally - // relocations against discarded sections are an error. However, debug info - // sections are not GC roots and can end up with these kinds of relocations. - // Skip these relocations. - if (!OS && !isa<DefinedAbsolute>(Sym) && !isa<DefinedSynthetic>(Sym)) { - if (isCodeView() || isDWARF()) - continue; - fatal("relocation against symbol in discarded section: " + - Sym->getName()); + // Skip the relocation if it refers to a discarded section, and diagnose it + // as an error if appropriate. If a symbol was discarded early, it may be + // null. If it was discarded late, the output section will be null, unless + // it was an absolute or synthetic symbol. + if (!Sym || + (!OS && !isa<DefinedAbsolute>(Sym) && !isa<DefinedSynthetic>(Sym))) { + maybeReportRelocationToDiscarded(this, Sym, Rel); + continue; } + uint64_t S = Sym->getRVA(); // Compute the RVA of the relocation for relative relocations. @@ -399,17 +443,125 @@ static uint8_t getBaserelType(const coff_relocation &R // fixed by the loader if load-time relocation is needed. // Only called when base relocation is enabled. void SectionChunk::getBaserels(std::vector<Baserel> *Res) { - for (const coff_relocation &Rel : Relocs) { + for (size_t I = 0, E = Relocs.size(); I < E; I++) { + const coff_relocation &Rel = Relocs[I]; uint8_t Ty = getBaserelType(Rel); if (Ty == IMAGE_REL_BASED_ABSOLUTE) continue; - Symbol *Target = File->getSymbol(Rel.SymbolTableIndex); + // Use the potentially remapped Symbol instead of the one that the + // relocation points to. + Symbol *Target = RelocTargets[I]; if (!Target || isa<DefinedAbsolute>(Target)) continue; Res->emplace_back(RVA + Rel.VirtualAddress, Ty); } } +// MinGW specific. +// Check whether a static relocation of type Type can be deferred and +// handled at runtime as a pseudo relocation (for references to a module +// local variable, which turned out to actually need to be imported from +// another DLL) This returns the size the relocation is supposed to update, +// in bits, or 0 if the relocation cannot be handled as a runtime pseudo +// relocation. +static int getRuntimePseudoRelocSize(uint16_t Type) { + // Relocations that either contain an absolute address, or a plain + // relative offset, since the runtime pseudo reloc implementation + // adds 8/16/32/64 bit values to a memory address. + // + // Given a pseudo relocation entry, + // + // typedef struct { + // DWORD sym; + // DWORD target; + // DWORD flags; + // } runtime_pseudo_reloc_item_v2; + // + // the runtime relocation performs this adjustment: + // *(base + .target) += *(base + .sym) - (base + .sym) + // + // This works for both absolute addresses (IMAGE_REL_*_ADDR32/64, + // IMAGE_REL_I386_DIR32, where the memory location initially contains + // the address of the IAT slot, and for relative addresses (IMAGE_REL*_REL32), + // where the memory location originally contains the relative offset to the + // IAT slot. + // + // This requires the target address to be writable, either directly out of + // the image, or temporarily changed at runtime with VirtualProtect. + // Since this only operates on direct address values, it doesn't work for + // ARM/ARM64 relocations, other than the plain ADDR32/ADDR64 relocations. + switch (Config->Machine) { + case AMD64: + switch (Type) { + case IMAGE_REL_AMD64_ADDR64: + return 64; + case IMAGE_REL_AMD64_ADDR32: + case IMAGE_REL_AMD64_REL32: + case IMAGE_REL_AMD64_REL32_1: + case IMAGE_REL_AMD64_REL32_2: + case IMAGE_REL_AMD64_REL32_3: + case IMAGE_REL_AMD64_REL32_4: + case IMAGE_REL_AMD64_REL32_5: + return 32; + default: + return 0; + } + case I386: + switch (Type) { + case IMAGE_REL_I386_DIR32: + case IMAGE_REL_I386_REL32: + return 32; + default: + return 0; + } + case ARMNT: + switch (Type) { + case IMAGE_REL_ARM_ADDR32: + return 32; + default: + return 0; + } + case ARM64: + switch (Type) { + case IMAGE_REL_ARM64_ADDR64: + return 64; + case IMAGE_REL_ARM64_ADDR32: + return 32; + default: + return 0; + } + default: + llvm_unreachable("unknown machine type"); + } +} + +// MinGW specific. +// Append information to the provided vector about all relocations that +// need to be handled at runtime as runtime pseudo relocations (references +// to a module local variable, which turned out to actually need to be +// imported from another DLL). +void SectionChunk::getRuntimePseudoRelocs( + std::vector<RuntimePseudoReloc> &Res) { + for (const coff_relocation &Rel : Relocs) { + auto *Target = + dyn_cast_or_null<Defined>(File->getSymbol(Rel.SymbolTableIndex)); + if (!Target || !Target->IsRuntimePseudoReloc) + continue; + int SizeInBits = getRuntimePseudoRelocSize(Rel.Type); + if (SizeInBits == 0) { + error("unable to automatically import from " + Target->getName() + + " with relocation type " + + File->getCOFFObj()->getRelocationTypeName(Rel.Type) + " in " + + toString(File)); + continue; + } + // SizeInBits is used to initialize the Flags field; currently no + // other flags are defined. + Res.emplace_back( + RuntimePseudoReloc(Target, this, Rel.VirtualAddress, SizeInBits)); + } +} + bool SectionChunk::hasData() const { return !(Header->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA); } @@ -447,6 +599,13 @@ void SectionChunk::replace(SectionChunk *Other) { Other->Live = false; } +uint32_t SectionChunk::getSectionNumber() const { + DataRefImpl R; + R.p = reinterpret_cast<uintptr_t>(Header); + SectionRef S(R, File->getCOFFObj()); + return S.getIndex() + 1; +} + CommonChunk::CommonChunk(const COFFSymbolRef S) : Sym(S) { // Common symbols are aligned on natural boundaries up to 32 bytes. // This is what MSVC link.exe does. @@ -460,6 +619,7 @@ uint32_t CommonChunk::getOutputCharacteristics() const void StringChunk::writeTo(uint8_t *Buf) const { memcpy(Buf + OutputSectionOff, Str.data(), Str.size()); + Buf[OutputSectionOff + Str.size()] = '\0'; } ImportThunkChunkX64::ImportThunkChunkX64(Defined *S) : ImpSymbol(S) { @@ -502,13 +662,30 @@ void ImportThunkChunkARM64::writeTo(uint8_t *Buf) cons applyArm64Ldr(Buf + OutputSectionOff + 4, Off); } +// A Thumb2, PIC, non-interworking range extension thunk. +const uint8_t ArmThunk[] = { + 0x40, 0xf2, 0x00, 0x0c, // P: movw ip,:lower16:S - (P + (L1-P) + 4) + 0xc0, 0xf2, 0x00, 0x0c, // movt ip,:upper16:S - (P + (L1-P) + 4) + 0xe7, 0x44, // L1: add pc, ip +}; + +size_t RangeExtensionThunk::getSize() const { + assert(Config->Machine == ARMNT); + return sizeof(ArmThunk); +} + +void RangeExtensionThunk::writeTo(uint8_t *Buf) const { + assert(Config->Machine == ARMNT); + uint64_t Offset = Target->getRVA() - RVA - 12; + memcpy(Buf + OutputSectionOff, ArmThunk, sizeof(ArmThunk)); + applyMOV32T(Buf + OutputSectionOff, uint32_t(Offset)); +} + void LocalImportChunk::getBaserels(std::vector<Baserel> *Res) { Res->emplace_back(getRVA()); } -size_t LocalImportChunk::getSize() const { - return Config->is64() ? 8 : 4; -} +size_t LocalImportChunk::getSize() const { return Config->Wordsize; } void LocalImportChunk::writeTo(uint8_t *Buf) const { if (Config->is64()) { @@ -528,6 +705,34 @@ void RVATableChunk::writeTo(uint8_t *Buf) const { "RVA tables should be de-duplicated"); } +// MinGW specific, for the "automatic import of variables from DLLs" feature. +size_t PseudoRelocTableChunk::getSize() const { + if (Relocs.empty()) + return 0; + return 12 + 12 * Relocs.size(); +} + +// MinGW specific. +void PseudoRelocTableChunk::writeTo(uint8_t *Buf) const { + if (Relocs.empty()) + return; + + ulittle32_t *Table = reinterpret_cast<ulittle32_t *>(Buf + OutputSectionOff); + // This is the list header, to signal the runtime pseudo relocation v2 + // format. + Table[0] = 0; + Table[1] = 0; + Table[2] = 1; + + size_t Idx = 3; + for (const RuntimePseudoReloc &RPR : Relocs) { + Table[Idx + 0] = RPR.Sym->getRVA(); + Table[Idx + 1] = RPR.Target->getRVA() + RPR.TargetOffset; + Table[Idx + 2] = RPR.Flags; + Idx += 3; + } +} + // Windows-specific. This class represents a block in .reloc section. // The format is described here. // @@ -613,13 +818,16 @@ void MergeChunk::addSection(SectionChunk *C) { } void MergeChunk::finalizeContents() { - for (SectionChunk *C : Sections) - if (C->isLive()) - Builder.add(toStringRef(C->getContents())); - Builder.finalize(); + if (!Finalized) { + for (SectionChunk *C : Sections) + if (C->Live) + Builder.add(toStringRef(C->getContents())); + Builder.finalize(); + Finalized = true; + } for (SectionChunk *C : Sections) { - if (!C->isLive()) + if (!C->Live) continue; size_t Off = Builder.getOffset(toStringRef(C->getContents())); C->setOutputSection(Out); @@ -638,6 +846,17 @@ size_t MergeChunk::getSize() const { void MergeChunk::writeTo(uint8_t *Buf) const { Builder.write(Buf + OutputSectionOff); +} + +// MinGW specific. +size_t AbsolutePointerChunk::getSize() const { return Config->Wordsize; } + +void AbsolutePointerChunk::writeTo(uint8_t *Buf) const { + if (Config->is64()) { + write64le(Buf + OutputSectionOff, Value); + } else { + write32le(Buf + OutputSectionOff, Value); + } } } // namespace coff Modified: vendor/lld/dist/COFF/Chunks.h ============================================================================== --- vendor/lld/dist/COFF/Chunks.h Sat Jan 19 10:05:41 2019 (r343178) +++ vendor/lld/dist/COFF/Chunks.h Sat Jan 19 10:05:49 2019 (r343179) @@ -36,6 +36,7 @@ class DefinedImportData; class DefinedRegular; class ObjFile; class OutputSection; +class RuntimePseudoReloc; class Symbol; // Mask for permissions (discardable, writable, readable, executable, etc). @@ -63,6 +64,13 @@ class Chunk { (public) // before calling this function. virtual void writeTo(uint8_t *Buf) const {} + // Called by the writer once before assigning addresses and writing + // the output. + virtual void readRelocTargets() {} + + // Called if restarting thunk addition. + virtual void resetRelocTargets() {} + // Called by the writer after an RVA is assigned, but before calling // getSize(). virtual void finalizeContents() {} @@ -114,6 +122,10 @@ class Chunk { (public) public: // The offset from beginning of the output section. The writer sets a value. uint64_t OutputSectionOff = 0; + + // Whether this section needs to be kept distinct from other sections during + // ICF. This is set by the driver using address-significance tables. + bool KeepUnique = false; }; // A chunk corresponding a section of an input file. @@ -140,6 +152,8 @@ class SectionChunk final : public Chunk { (public) SectionChunk(ObjFile *File, const coff_section *Header); static bool classof(const Chunk *C) { return C->kind() == SectionKind; } + void readRelocTargets() override; + void resetRelocTargets() override; size_t getSize() const override { return Header->SizeOfRawData; } ArrayRef<uint8_t> getContents() const; void writeTo(uint8_t *Buf) const override; @@ -157,6 +171,8 @@ class SectionChunk final : public Chunk { (public) void applyRelARM64(uint8_t *Off, uint16_t Type, OutputSection *OS, uint64_t S, uint64_t P) const; + void getRuntimePseudoRelocs(std::vector<RuntimePseudoReloc> &Res); + // Called if the garbage collector decides to not include this chunk // in a final output. It's supposed to print out a log message to stdout. void printDiscardedMessage() const; @@ -167,16 +183,6 @@ class SectionChunk final : public Chunk { (public) StringRef getDebugName() override; - // Returns true if the chunk was not dropped by GC. - bool isLive() { return Live; } - - // Used by the garbage collector. - void markLive() { - assert(Config->DoGC && "should only mark things live from GC"); - assert(!isLive() && "Cannot mark an already live section!"); - Live = true; - } - // True if this is a codeview debug info chunk. These will not be laid out in // the image. Instead they will end up in the PDB, if one is requested. bool isCodeView() const { @@ -197,10 +203,13 @@ class SectionChunk final : public Chunk { (public) // Allow iteration over the associated child chunks for this section. ArrayRef<SectionChunk *> children() const { return AssocChildren; } + // The section ID this chunk belongs to in its Obj. + uint32_t getSectionNumber() const; + // A pointer pointing to a replacement for this chunk. // Initially it points to "this" object. If this chunk is merged // with other chunk by ICF, it points to another chunk, - // and this chunk is considrered as dead. + // and this chunk is considered as dead. SectionChunk *Repl; // The CRC of the contents as described in the COFF spec 4.5.5. @@ -217,13 +226,17 @@ class SectionChunk final : public Chunk { (public) ArrayRef<coff_relocation> Relocs; + // Used by the garbage collector. + bool Live; + + // When inserting a thunk, we need to adjust a relocation to point to + // the thunk instead of the actual original target Symbol. + std::vector<Symbol *> RelocTargets; + private: StringRef SectionName; std::vector<SectionChunk *> AssocChildren; - // Used by the garbage collector. - bool Live; - // Used for ICF (Identical COMDAT Folding) void replace(SectionChunk *Other); uint32_t Class[2] = {0, 0}; @@ -254,6 +267,7 @@ class MergeChunk : public Chunk { (public) private: llvm::StringTableBuilder Builder; + bool Finalized = false; }; // A chunk for common symbols. Common chunks don't have actual data. @@ -297,7 +311,7 @@ static const uint8_t ImportThunkARM64[] = { }; // Windows-specific. -// A chunk for DLL import jump table entry. In a final output, it's +// A chunk for DLL import jump table entry. In a final output, its // contents will be a JMP instruction to some __imp_ symbol. class ImportThunkChunkX64 : public Chunk { public: @@ -341,11 +355,22 @@ class ImportThunkChunkARM64 : public Chunk { (private) Defined *ImpSymbol; }; +class RangeExtensionThunk : public Chunk { +public: + explicit RangeExtensionThunk(Defined *T) : Target(T) {} + size_t getSize() const override; + void writeTo(uint8_t *Buf) const override; + + Defined *Target; +}; + // Windows-specific. // See comments for DefinedLocalImport class. class LocalImportChunk : public Chunk { public: - explicit LocalImportChunk(Defined *S) : Sym(S) {} + explicit LocalImportChunk(Defined *S) : Sym(S) { + Alignment = Config->Wordsize; + } size_t getSize() const override; void getBaserels(std::vector<Baserel> *Res) override; void writeTo(uint8_t *Buf) const override; @@ -414,8 +439,72 @@ class Baserel { (public) uint8_t Type; }; +// This is a placeholder Chunk, to allow attaching a DefinedSynthetic to a +// specific place in a section, without any data. This is used for the MinGW +// specific symbol __RUNTIME_PSEUDO_RELOC_LIST_END__, even though the concept +// of an empty chunk isn't MinGW specific. +class EmptyChunk : public Chunk { +public: + EmptyChunk() {} + size_t getSize() const override { return 0; } + void writeTo(uint8_t *Buf) const override {} +}; + +// MinGW specific, for the "automatic import of variables from DLLs" feature. +// This provides the table of runtime pseudo relocations, for variable +// references that turned out to need to be imported from a DLL even though +// the reference didn't use the dllimport attribute. The MinGW runtime will +// process this table after loading, before handling control over to user +// code. +class PseudoRelocTableChunk : public Chunk { +public: + PseudoRelocTableChunk(std::vector<RuntimePseudoReloc> &Relocs) + : Relocs(std::move(Relocs)) { + Alignment = 4; + } + size_t getSize() const override; + void writeTo(uint8_t *Buf) const override; + +private: + std::vector<RuntimePseudoReloc> Relocs; +}; + +// MinGW specific; information about one individual location in the image +// that needs to be fixed up at runtime after loading. This represents +// one individual element in the PseudoRelocTableChunk table. +class RuntimePseudoReloc { +public: + RuntimePseudoReloc(Defined *Sym, SectionChunk *Target, uint32_t TargetOffset, + int Flags) + : Sym(Sym), Target(Target), TargetOffset(TargetOffset), Flags(Flags) {} + + Defined *Sym; + SectionChunk *Target; + uint32_t TargetOffset; + // The Flags field contains the size of the relocation, in bits. No other + // flags are currently defined. + int Flags; +}; + +// MinGW specific. A Chunk that contains one pointer-sized absolute value. +class AbsolutePointerChunk : public Chunk { +public: + AbsolutePointerChunk(uint64_t Value) : Value(Value) { + Alignment = getSize(); + } + size_t getSize() const override; + void writeTo(uint8_t *Buf) const override; + +private: + uint64_t Value; +}; + void applyMOV32T(uint8_t *Off, uint32_t V); void applyBranch24T(uint8_t *Off, int32_t V); + +void applyArm64Addr(uint8_t *Off, uint64_t S, uint64_t P, int Shift); +void applyArm64Imm(uint8_t *Off, uint64_t Imm, uint32_t RangeLimit); +void applyArm64Branch26(uint8_t *Off, int64_t V); } // namespace coff } // namespace lld Modified: vendor/lld/dist/COFF/Config.h ============================================================================== --- vendor/lld/dist/COFF/Config.h Sat Jan 19 10:05:41 2019 (r343178) +++ vendor/lld/dist/COFF/Config.h Sat Jan 19 10:05:49 2019 (r343179) @@ -84,6 +84,7 @@ struct Configuration { bool is64() { return Machine == AMD64 || Machine == ARM64; } llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN; + size_t Wordsize; bool Verbose = false; WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN; Symbol *Entry = nullptr; @@ -94,7 +95,8 @@ struct Configuration { bool DoICF = true; bool TailMerge; bool Relocatable = true; - bool Force = false; + bool ForceMultiple = false; + bool ForceUnresolved = false; bool Debug = false; bool DebugDwarf = false; bool DebugGHashes = false; @@ -195,6 +197,7 @@ struct Configuration { bool MinGW = false; bool WarnMissingOrderSymbol = true; bool WarnLocallyDefinedImported = true; + bool WarnDebugInfoUnusable = true; bool Incremental = true; bool IntegrityCheck = false; bool KillAt = false; Modified: vendor/lld/dist/COFF/DLL.cpp ============================================================================== --- vendor/lld/dist/COFF/DLL.cpp Sat Jan 19 10:05:41 2019 (r343178) +++ vendor/lld/dist/COFF/DLL.cpp Sat Jan 19 10:05:49 2019 (r343179) @@ -35,8 +35,6 @@ namespace { // Import table -static int ptrSize() { return Config->is64() ? 8 : 4; } - // A chunk for the import descriptor table. class HintNameChunk : public Chunk { public: @@ -61,8 +59,8 @@ class HintNameChunk : public Chunk { (private) // A chunk for the import descriptor table. class LookupChunk : public Chunk { public: - explicit LookupChunk(Chunk *C) : HintName(C) { Alignment = ptrSize(); } - size_t getSize() const override { return ptrSize(); } + explicit LookupChunk(Chunk *C) : HintName(C) { Alignment = Config->Wordsize; } + size_t getSize() const override { return Config->Wordsize; } void writeTo(uint8_t *Buf) const override { write32le(Buf + OutputSectionOff, HintName->getRVA()); @@ -76,8 +74,10 @@ class LookupChunk : public Chunk { (public) // See Microsoft PE/COFF spec 7.1. Import Header for details. class OrdinalOnlyChunk : public Chunk { public: - explicit OrdinalOnlyChunk(uint16_t V) : Ordinal(V) { Alignment = ptrSize(); } - size_t getSize() const override { return ptrSize(); } + explicit OrdinalOnlyChunk(uint16_t V) : Ordinal(V) { + Alignment = Config->Wordsize; + } + size_t getSize() const override { return Config->Wordsize; } void writeTo(uint8_t *Buf) const override { // An import-by-ordinal slot has MSB 1 to indicate that @@ -230,6 +230,36 @@ static const uint8_t ThunkARM[] = { 0x60, 0x47, // bx ip }; +static const uint8_t ThunkARM64[] = { + 0x11, 0x00, 0x00, 0x90, // adrp x17, #0 __imp_<FUNCNAME> + 0x31, 0x02, 0x00, 0x91, // add x17, x17, #0 :lo12:__imp_<FUNCNAME> + 0xfd, 0x7b, 0xb3, 0xa9, // stp x29, x30, [sp, #-208]! + 0xfd, 0x03, 0x00, 0x91, // mov x29, sp + 0xe0, 0x07, 0x01, 0xa9, // stp x0, x1, [sp, #16] + 0xe2, 0x0f, 0x02, 0xa9, // stp x2, x3, [sp, #32] + 0xe4, 0x17, 0x03, 0xa9, // stp x4, x5, [sp, #48] + 0xe6, 0x1f, 0x04, 0xa9, // stp x6, x7, [sp, #64] + 0xe0, 0x87, 0x02, 0xad, // stp q0, q1, [sp, #80] + 0xe2, 0x8f, 0x03, 0xad, // stp q2, q3, [sp, #112] + 0xe4, 0x97, 0x04, 0xad, // stp q4, q5, [sp, #144] + 0xe6, 0x9f, 0x05, 0xad, // stp q6, q7, [sp, #176] + 0xe1, 0x03, 0x11, 0xaa, // mov x1, x17 + 0x00, 0x00, 0x00, 0x90, // adrp x0, #0 DELAY_IMPORT_DESCRIPTOR + 0x00, 0x00, 0x00, 0x91, // add x0, x0, #0 :lo12:DELAY_IMPORT_DESCRIPTOR + 0x00, 0x00, 0x00, 0x94, // bl #0 __delayLoadHelper2 + 0xf0, 0x03, 0x00, 0xaa, // mov x16, x0 + 0xe6, 0x9f, 0x45, 0xad, // ldp q6, q7, [sp, #176] + 0xe4, 0x97, 0x44, 0xad, // ldp q4, q5, [sp, #144] + 0xe2, 0x8f, 0x43, 0xad, // ldp q2, q3, [sp, #112] + 0xe0, 0x87, 0x42, 0xad, // ldp q0, q1, [sp, #80] + 0xe6, 0x1f, 0x44, 0xa9, // ldp x6, x7, [sp, #64] + 0xe4, 0x17, 0x43, 0xa9, // ldp x4, x5, [sp, #48] + 0xe2, 0x0f, 0x42, 0xa9, // ldp x2, x3, [sp, #32] + 0xe0, 0x07, 0x41, 0xa9, // ldp x0, x1, [sp, #16] + 0xfd, 0x7b, 0xcd, 0xa8, // ldp x29, x30, [sp], #208 + 0x00, 0x02, 0x1f, 0xd6, // br x16 +}; + // A chunk for the delay import thunk. class ThunkChunkX64 : public Chunk { public: @@ -298,11 +328,35 @@ class ThunkChunkARM : public Chunk { (public) Defined *Helper = nullptr; }; +class ThunkChunkARM64 : public Chunk { +public: + ThunkChunkARM64(Defined *I, Chunk *D, Defined *H) + : Imp(I), Desc(D), Helper(H) {} + + size_t getSize() const override { return sizeof(ThunkARM64); } + + void writeTo(uint8_t *Buf) const override { + memcpy(Buf + OutputSectionOff, ThunkARM64, sizeof(ThunkARM64)); + applyArm64Addr(Buf + OutputSectionOff + 0, Imp->getRVA(), RVA + 0, 12); + applyArm64Imm(Buf + OutputSectionOff + 4, Imp->getRVA() & 0xfff, 0); + applyArm64Addr(Buf + OutputSectionOff + 52, Desc->getRVA(), RVA + 52, 12); + applyArm64Imm(Buf + OutputSectionOff + 56, Desc->getRVA() & 0xfff, 0); + applyArm64Branch26(Buf + OutputSectionOff + 60, + Helper->getRVA() - RVA - 60); + } + + Defined *Imp = nullptr; + Chunk *Desc = nullptr; + Defined *Helper = nullptr; +}; + // A chunk for the import descriptor table. class DelayAddressChunk : public Chunk { public: - explicit DelayAddressChunk(Chunk *C) : Thunk(C) { Alignment = ptrSize(); } - size_t getSize() const override { return ptrSize(); } + explicit DelayAddressChunk(Chunk *C) : Thunk(C) { + Alignment = Config->Wordsize; + } + size_t getSize() const override { return Config->Wordsize; } void writeTo(uint8_t *Buf) const override { if (Config->is64()) { @@ -362,6 +416,8 @@ class AddressTableChunk : public Chunk { (public) size_t getSize() const override { return Size * 4; } void writeTo(uint8_t *Buf) const override { + memset(Buf + OutputSectionOff, 0, getSize()); + for (const Export &E : Config->Exports) { uint8_t *P = Buf + OutputSectionOff + E.Ordinal * 4; uint32_t Bit = 0; @@ -418,30 +474,6 @@ class ExportOrdinalChunk : public Chunk { (private) } // anonymous namespace -uint64_t IdataContents::getDirSize() { - return Dirs.size() * sizeof(ImportDirectoryTableEntry); -} - -uint64_t IdataContents::getIATSize() { - return Addresses.size() * ptrSize(); -} - -// Returns a list of .idata contents. -// See Microsoft PE/COFF spec 5.4 for details. -std::vector<Chunk *> IdataContents::getChunks() { - create(); - - // The loader assumes a specific order of data. - // Add each type in the correct order. - std::vector<Chunk *> V; - V.insert(V.end(), Dirs.begin(), Dirs.end()); - V.insert(V.end(), Lookups.begin(), Lookups.end()); - V.insert(V.end(), Addresses.begin(), Addresses.end()); - V.insert(V.end(), Hints.begin(), Hints.end()); - V.insert(V.end(), DLLNames.begin(), DLLNames.end()); - return V; -} - void IdataContents::create() { std::vector<std::vector<DefinedImportData *>> V = binImports(Imports); @@ -465,8 +497,8 @@ void IdataContents::create() { Hints.push_back(C); } // Terminate with null values. - Lookups.push_back(make<NullChunk>(ptrSize())); - Addresses.push_back(make<NullChunk>(ptrSize())); + Lookups.push_back(make<NullChunk>(Config->Wordsize)); + Addresses.push_back(make<NullChunk>(Config->Wordsize)); for (int I = 0, E = Syms.size(); I < E; ++I) Syms[I]->setLocation(Addresses[Base + I]); @@ -555,6 +587,8 @@ Chunk *DelayLoadContents::newThunkChunk(DefinedImportD return make<ThunkChunkX86>(S, Dir, Helper); case ARMNT: return make<ThunkChunkARM>(S, Dir, Helper); + case ARM64: + return make<ThunkChunkARM64>(S, Dir, Helper); default: llvm_unreachable("unsupported machine type"); } Modified: vendor/lld/dist/COFF/DLL.h ============================================================================== --- vendor/lld/dist/COFF/DLL.h Sat Jan 19 10:05:41 2019 (r343178) +++ vendor/lld/dist/COFF/DLL.h Sat Jan 19 10:05:49 2019 (r343179) @@ -19,19 +19,12 @@ namespace coff { // Windows-specific. // IdataContents creates all chunks for the DLL import table. // You are supposed to call add() to add symbols and then -// call getChunks() to get a list of chunks. +// call create() to populate the chunk vectors. class IdataContents { public: void add(DefinedImportData *Sym) { Imports.push_back(Sym); } bool empty() { return Imports.empty(); } - std::vector<Chunk *> getChunks(); - uint64_t getDirRVA() { return Dirs[0]->getRVA(); } - uint64_t getDirSize(); - uint64_t getIATRVA() { return Addresses[0]->getRVA(); } - uint64_t getIATSize(); - -private: void create(); std::vector<DefinedImportData *> Imports; Modified: vendor/lld/dist/COFF/Driver.cpp ============================================================================== --- vendor/lld/dist/COFF/Driver.cpp Sat Jan 19 10:05:41 2019 (r343178) +++ vendor/lld/dist/COFF/Driver.cpp Sat Jan 19 10:05:49 2019 (r343179) @@ -32,6 +32,7 @@ #include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/LEB128.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" #include "llvm/Support/TarWriter.h" @@ -56,7 +57,7 @@ Configuration *Config; LinkerDriver *Driver; bool link(ArrayRef<const char *> Args, bool CanExitEarly, raw_ostream &Diag) { - errorHandler().LogName = sys::path::filename(Args[0]); + errorHandler().LogName = args::getFilenameWithoutExe(Args[0]); errorHandler().ErrorOS = &Diag; errorHandler().ColorDiagnostics = Diag.has_colors(); errorHandler().ErrorLimitExceededMsg = @@ -116,6 +117,19 @@ static std::future<MBErrPair> createFutureForFile(std: }); } +// Symbol names are mangled by prepending "_" on x86. +static StringRef mangle(StringRef Sym) { + assert(Config->Machine != IMAGE_FILE_MACHINE_UNKNOWN); *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201901191005.x0JA5n91041216>