Date: Wed, 30 Jan 2019 07:09:02 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r343570 - projects/clang800-import/contrib/llvm/tools/lld/ELF Message-ID: <201901300709.x0U792dF033077@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Wed Jan 30 07:09:01 2019 New Revision: 343570 URL: https://svnweb.freebsd.org/changeset/base/343570 Log: Pull in r352407 from upstream lld trunk (by Rui Ueyama): Refactoring. NFC. Pull in r352435 from upstream lld trunk (by Rui Ueyama): Attempt to fix build failure with GCC 5.4. Pull in r352482 from upstream lld trunk (by George Rimar): [ELF] - Remove dead `readBfdName` declaration. NFC. `readBfdName` was removed recently. Pull in r352606 from upstream lld trunk (by me): Recognize FreeBSD specific BFD names in OUTPUT_FORMAT Summary: After rLLD344952 ("Add OUTPUT_FORMAT linker script directive support"), using BFD names such as `elf64-x86-64-freebsd` the `OUTPUT_FORMAT` linker script command does not work anymore, resulting in errors like: ``` ld: error: /home/dim/src/clang800-import/stand/efi/loader/arch/amd64/ldscript.amd64:2: unknown output format name: elf64-x86-64-freebsd >>> OUTPUT_FORMAT("elf64-x86-64-freebsd", "elf64-x86-64-freebsd", "elf64-x86-64-freebsd") >>> ^ ``` To fix this, recognize a `-freebsd` suffix in BFD names, and also set `Configuration::OSABI` to `ELFOSABI_FREEBSD` for those cases. Add and/or update several test cases to check for the correct results of these new `OUTPUT_FORMAT` arguments. Reviewers: ruiu, atanasyan, grimar, hokein, emaste, espindola Reviewed By: ruiu Subscribers: nemanjai, javed.absar, arichardson, krytarowski, kristof.beyls, kbarton, llvm-commits Differential Revision: https://reviews.llvm.org/D57283 Modified: projects/clang800-import/contrib/llvm/tools/lld/ELF/ScriptParser.cpp Modified: projects/clang800-import/contrib/llvm/tools/lld/ELF/ScriptParser.cpp ============================================================================== --- projects/clang800-import/contrib/llvm/tools/lld/ELF/ScriptParser.cpp Wed Jan 30 05:39:47 2019 (r343569) +++ projects/clang800-import/contrib/llvm/tools/lld/ELF/ScriptParser.cpp Wed Jan 30 07:09:01 2019 (r343570) @@ -94,7 +94,6 @@ class ScriptParser final : ScriptLexer { (private) SortSectionPolicy readSortKind(); SymbolAssignment *readProvideHidden(bool Provide, bool Hidden); SymbolAssignment *readAssignment(StringRef Tok); - std::tuple<ELFKind, uint16_t, bool> readBfdName(); void readSort(); Expr readAssert(); Expr readConstant(); @@ -385,39 +384,24 @@ void ScriptParser::readOutputArch() { skip(); } -std::tuple<ELFKind, uint16_t, bool> ScriptParser::readBfdName() { - StringRef S = unquote(next()); - if (S == "elf32-i386") - return std::make_tuple(ELF32LEKind, EM_386, false); - if (S == "elf32-iamcu") - return std::make_tuple(ELF32LEKind, EM_IAMCU, false); - if (S == "elf32-littlearm") - return std::make_tuple(ELF32LEKind, EM_ARM, false); - if (S == "elf32-x86-64") - return std::make_tuple(ELF32LEKind, EM_X86_64, false); - if (S == "elf64-littleaarch64") - return std::make_tuple(ELF64LEKind, EM_AARCH64, false); - if (S == "elf64-powerpc") - return std::make_tuple(ELF64BEKind, EM_PPC64, false); - if (S == "elf64-powerpcle") - return std::make_tuple(ELF64LEKind, EM_PPC64, false); - if (S == "elf64-x86-64") - return std::make_tuple(ELF64LEKind, EM_X86_64, false); - if (S == "elf32-tradbigmips") - return std::make_tuple(ELF32BEKind, EM_MIPS, false); - if (S == "elf32-ntradbigmips") - return std::make_tuple(ELF32BEKind, EM_MIPS, true); - if (S == "elf32-tradlittlemips") - return std::make_tuple(ELF32LEKind, EM_MIPS, false); - if (S == "elf32-ntradlittlemips") - return std::make_tuple(ELF32LEKind, EM_MIPS, true); - if (S == "elf64-tradbigmips") - return std::make_tuple(ELF64BEKind, EM_MIPS, false); - if (S == "elf64-tradlittlemips") - return std::make_tuple(ELF64LEKind, EM_MIPS, false); - - setError("unknown output format name: " + S); - return std::make_tuple(ELFNoneKind, EM_NONE, false); +static std::pair<ELFKind, uint16_t> parseBfdName(StringRef S) { + return StringSwitch<std::pair<ELFKind, uint16_t>>(S) + .Case("elf32-i386", {ELF32LEKind, EM_386}) + .Case("elf32-iamcu", {ELF32LEKind, EM_IAMCU}) + .Case("elf32-littlearm", {ELF32LEKind, EM_ARM}) + .Case("elf32-x86-64", {ELF32LEKind, EM_X86_64}) + .Case("elf64-aarch64", {ELF64LEKind, EM_AARCH64}) + .Case("elf64-littleaarch64", {ELF64LEKind, EM_AARCH64}) + .Case("elf64-powerpc", {ELF64BEKind, EM_PPC64}) + .Case("elf64-powerpcle", {ELF64LEKind, EM_PPC64}) + .Case("elf64-x86-64", {ELF64LEKind, EM_X86_64}) + .Case("elf32-tradbigmips", {ELF32BEKind, EM_MIPS}) + .Case("elf32-ntradbigmips", {ELF32BEKind, EM_MIPS}) + .Case("elf32-tradlittlemips", {ELF32LEKind, EM_MIPS}) + .Case("elf32-ntradlittlemips", {ELF32LEKind, EM_MIPS}) + .Case("elf64-tradbigmips", {ELF64BEKind, EM_MIPS}) + .Case("elf64-tradlittlemips", {ELF64LEKind, EM_MIPS}) + .Default({ELFNoneKind, EM_NONE}); } // Parse OUTPUT_FORMAT(bfdname) or OUTPUT_FORMAT(bfdname, big, little). @@ -425,9 +409,16 @@ std::tuple<ELFKind, uint16_t, bool> ScriptParser::read void ScriptParser::readOutputFormat() { expect("("); - std::tuple<ELFKind, uint16_t, bool> BfdTuple = readBfdName(); - if (Config->EKind == ELFNoneKind) - std::tie(Config->EKind, Config->EMachine, Config->MipsN32Abi) = BfdTuple; + StringRef Name = unquote(next()); + StringRef S = Name; + if (S.consume_back("-freebsd")) + Config->OSABI = ELFOSABI_FREEBSD; + + std::tie(Config->EKind, Config->EMachine) = parseBfdName(S); + if (Config->EMachine == EM_NONE) + setError("unknown output format name: " + Name); + if (S == "elf32-ntradlittlemips" || S == "elf32-ntradbigmips") + Config->MipsN32Abi = true; if (consume(")")) return;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201901300709.x0U792dF033077>