<div dir="ltr">Probably best to collapse the "revert: revert: revert" chains to make these sort of commits easier to read/understand.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 22, 2023 at 5:34 AM Mitch Phillips via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Author: Mitch Phillips<br>
Date: 2023-06-22T14:33:57+02:00<br>
New Revision: cd116e046034aabe08c38c825497e6019bdb9f04<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/cd116e046034aabe08c38c825497e6019bdb9f04" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/cd116e046034aabe08c38c825497e6019bdb9f04</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/cd116e046034aabe08c38c825497e6019bdb9f04.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/cd116e046034aabe08c38c825497e6019bdb9f04.diff</a><br>
<br>
LOG: Revert "Revert "Revert "[LLD][ELF] Cortex-M Security Extensions (CMSE) Support"""<br>
<br>
This reverts commit 9246df7049b0bb83743f860caff4221413c63de2.<br>
<br>
Reason: This patch broke the UBSan buildbots. See more information in<br>
the original phabricator review: <a href="https://reviews.llvm.org/D139092" rel="noreferrer" target="_blank">https://reviews.llvm.org/D139092</a><br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    lld/ELF/Arch/ARM.cpp<br>
    lld/ELF/Config.h<br>
    lld/ELF/Driver.cpp<br>
    lld/ELF/InputFiles.cpp<br>
    lld/ELF/InputFiles.h<br>
    lld/ELF/LinkerScript.cpp<br>
    lld/ELF/LinkerScript.h<br>
    lld/ELF/MarkLive.cpp<br>
    lld/ELF/Options.td<br>
    lld/ELF/SymbolTable.h<br>
    lld/ELF/SyntheticSections.cpp<br>
    lld/ELF/SyntheticSections.h<br>
    lld/ELF/Target.h<br>
    lld/ELF/Writer.cpp<br>
<br>
Removed: <br>
    lld/test/ELF/Inputs/arm-cmse-macros.s<br>
    lld/test/ELF/aarch64-cmse.s<br>
    lld/test/ELF/arm-cmse-diagnostics.s<br>
    lld/test/ELF/arm-cmse-implib.s<br>
    lld/test/ELF/arm-cmse-keep-sections.s<br>
    lld/test/ELF/arm-cmse-noveneers.s<br>
    lld/test/ELF/arm-cmse-secure.s<br>
    lld/test/ELF/arm-cmse-veneers.s<br>
<br>
<br>
################################################################################<br>
diff  --git a/lld/ELF/Arch/ARM.cpp b/lld/ELF/Arch/ARM.cpp<br>
index 2c0e21e01932f..79635a22df4ec 100644<br>
--- a/lld/ELF/Arch/ARM.cpp<br>
+++ b/lld/ELF/Arch/ARM.cpp<br>
@@ -6,14 +6,10 @@<br>
 //<br>
 //===----------------------------------------------------------------------===//<br>
<br>
-#include "InputFiles.h"<br>
-#include "OutputSections.h"<br>
-#include "SymbolTable.h"<br>
 #include "Symbols.h"<br>
 #include "SyntheticSections.h"<br>
 #include "Target.h"<br>
 #include "lld/Common/ErrorHandler.h"<br>
-#include "lld/Common/Filesystem.h"<br>
 #include "llvm/BinaryFormat/ELF.h"<br>
 #include "llvm/Support/Endian.h"<br>
<br>
@@ -23,7 +19,6 @@ using namespace llvm::support;<br>
 using namespace llvm::ELF;<br>
 using namespace lld;<br>
 using namespace lld::elf;<br>
-using namespace llvm::object;<br>
<br>
 namespace {<br>
 class ARM final : public TargetInfo {<br>
@@ -915,413 +910,8 @@ int64_t ARM::getImplicitAddend(const uint8_t *buf, RelType type) const {<br>
   }<br>
 }<br>
<br>
-// The Arm Cortex-M Security Extensions (CMSE) splits a system into two parts;<br>
-// the non-secure and secure states with the secure state inaccessible from the<br>
-// non-secure state, apart from an area of memory in secure state called the<br>
-// secure gateway which is accessible from non-secure state. The secure gateway<br>
-// contains one or more entry points which must start with a landing pad<br>
-// instruction SG. Arm recommends that the secure gateway consists only of<br>
-// secure gateway veneers, which are made up of a SG instruction followed by a<br>
-// branch to the destination in secure state. Full details can be found in Arm<br>
-// v8-M Security Extensions Requirements on Development Tools.<br>
-//<br>
-// The CMSE model of software development requires the non-secure and secure<br>
-// states to be developed as two separate programs. The non-secure developer is<br>
-// provided with an import library defining symbols describing the entry points<br>
-// in the secure gateway. No additional linker support is required for the<br>
-// non-secure state.<br>
-//<br>
-// Development of the secure state requires linker support to manage the secure<br>
-// gateway veneers. The management consists of:<br>
-// - Creation of new secure gateway veneers based on symbol conventions.<br>
-// - Checking the address of existing secure gateway veneers.<br>
-// - Warning when existing secure gateway veneers removed.<br>
-//<br>
-// The secure gateway veneers are created in an import library, which is just an<br>
-// ELF object with a symbol table. The import library is controlled by two<br>
-// command line options:<br>
-// --in-implib (specify an input import library from a previous revision of the<br>
-// program).<br>
-// --out-implib (specify an output import library to be created by the linker).<br>
-//<br>
-// The input import library is used to manage consistency of the secure entry<br>
-// points. The output import library is for new and updated secure entry points.<br>
-//<br>
-// The symbol convention that identifies secure entry functions is the prefix<br>
-// __acle_se_ for a symbol called name the linker is expected to create a secure<br>
-// gateway veneer if symbols __acle_se_name and name have the same address.<br>
-// After creating a secure gateway veneer the symbol name labels the secure<br>
-// gateway veneer and the __acle_se_name labels the function definition.<br>
-//<br>
-// The LLD implementation:<br>
-// - Reads an existing import library with importCmseSymbols().<br>
-// - Determines which new secure gateway veneers to create and redirects calls<br>
-//   within the secure state to the __acle_se_ prefixed symbol with<br>
-//   processArmCmseSymbols().<br>
-// - Models the SG veneers as a synthetic section.<br>
-<br>
-// Initialize symbols. symbols is a parallel array to the corresponding ELF<br>
-// symbol table.<br>
-template <class ELFT> void ObjFile<ELFT>::importCmseSymbols() {<br>
-  ArrayRef<Elf_Sym> eSyms = getELFSyms<ELFT>();<br>
-  // Error for local symbols. The symbol at index 0 is LOCAL. So skip it.<br>
-  for (size_t i = 1, end = firstGlobal; i != end; ++i) {<br>
-    errorOrWarn("CMSE symbol '" + CHECK(eSyms[i].getName(stringTable), this) +<br>
-                "' in import library '" + toString(this) + "' is not global");<br>
-  }<br>
-<br>
-  for (size_t i = firstGlobal, end = eSyms.size(); i != end; ++i) {<br>
-    const Elf_Sym &eSym = eSyms[i];<br>
-    Defined *sym = reinterpret_cast<Defined *>(make<SymbolUnion>());<br>
-<br>
-    // Initialize symbol fields.<br>
-    memset(sym, 0, sizeof(Symbol));<br>
-    sym->setName(CHECK(eSyms[i].getName(stringTable), this));<br>
-    sym->value = eSym.st_value;<br>
-    sym->size = eSym.st_size;<br>
-    sym->type = eSym.getType();<br>
-    sym->binding = eSym.getBinding();<br>
-    sym->stOther = eSym.st_other;<br>
-<br>
-    if (eSym.st_shndx != SHN_ABS) {<br>
-      error("CMSE symbol '" + sym->getName() + "' in import library '" +<br>
-            toString(this) + "' is not absolute");<br>
-      continue;<br>
-    }<br>
-<br>
-    if (!(eSym.st_value & 1) || (eSym.getType() != STT_FUNC)) {<br>
-      error("CMSE symbol '" + sym->getName() + "' in import library '" +<br>
-            toString(this) + "' is not a Thumb function definition");<br>
-      continue;<br>
-    }<br>
-<br>
-    if (symtab.cmseImportLib.count(sym->getName())) {<br>
-      error("CMSE symbol '" + sym->getName() +<br>
-            "' is multiply defined in import library '" + toString(this) + "'");<br>
-      continue;<br>
-    }<br>
-<br>
-    if (eSym.st_size != ACLESESYM_SIZE) {<br>
-      warn("CMSE symbol '" + sym->getName() + "' in import library '" +<br>
-           toString(this) + "' does not have correct size of " +<br>
-           Twine(ACLESESYM_SIZE) + " bytes");<br>
-    }<br>
-<br>
-    symtab.cmseImportLib[sym->getName()] = sym;<br>
-  }<br>
-}<br>
-<br>
-// Check symbol attributes of the acleSeSym, sym pair.<br>
-// Both symbols should be global/weak Thumb code symbol definitions.<br>
-static std::string checkCmseSymAttributes(Symbol *acleSeSym, Symbol *sym) {<br>
-  auto check = [](Symbol *s, StringRef type) -> std::optional<std::string> {<br>
-    auto d = dyn_cast_or_null<Defined>(s);<br>
-    if (!(d && d->isFunc() && (d->value & 1)))<br>
-      return (Twine(toString(s->file)) + ": cmse " + type + " symbol '" +<br>
-              s->getName() + "' is not a Thumb function definition")<br>
-          .str();<br>
-    if (!d->section)<br>
-      return (Twine(toString(s->file)) + ": cmse " + type + " symbol '" +<br>
-              s->getName() + "' cannot be an absolute symbol")<br>
-          .str();<br>
-    return std::nullopt;<br>
-  };<br>
-  for (auto [sym, type] :<br>
-       {std::make_pair(acleSeSym, "special"), std::make_pair(sym, "entry")})<br>
-    if (auto err = check(sym, type))<br>
-      return *err;<br>
-  return "";<br>
-}<br>
-<br>
-// Look for [__acle_se_<sym>, <sym>] pairs, as specified in the Cortex-M<br>
-// Security Extensions specification.<br>
-// 1) <sym> : A standard function name.<br>
-// 2) __acle_se_<sym> : A special symbol that prefixes the standard function<br>
-// name with __acle_se_.<br>
-// Both these symbols are Thumb function symbols with external linkage.<br>
-// <sym> may be redefined in .gnu.sgstubs.<br>
-void elf::processArmCmseSymbols() {<br>
-  if (!config->cmseImplib)<br>
-    return;<br>
-  // Only symbols with external linkage end up in symtab, so no need to do<br>
-  // linkage checks. Only check symbol type.<br>
-  for (Symbol *acleSeSym : symtab.getSymbols()) {<br>
-    if (!acleSeSym->getName().startswith(ACLESESYM_PREFIX))<br>
-      continue;<br>
-    // If input object build attributes do not support CMSE, error and disable<br>
-    // further scanning for <sym>, __acle_se_<sym> pairs.<br>
-    if (!config->armCMSESupport) {<br>
-      error("CMSE is only supported by ARMv8-M architecture or later");<br>
-      config->cmseImplib = false;<br>
-      break;<br>
-    }<br>
-<br>
-    // Try to find the associated symbol definition.<br>
-    // Symbol must have external linkage.<br>
-    StringRef name = acleSeSym->getName().substr(std::strlen(ACLESESYM_PREFIX));<br>
-    Symbol *sym = symtab.find(name);<br>
-    if (!sym) {<br>
-      error(toString(acleSeSym->file) + ": cmse special symbol '" +<br>
-            acleSeSym->getName() +<br>
-            "' detected, but no associated entry function definition '" + name +<br>
-            "' with external linkage found");<br>
-      continue;<br>
-    }<br>
-<br>
-    std::string errMsg = checkCmseSymAttributes(acleSeSym, sym);<br>
-    if (!errMsg.empty()) {<br>
-      error(errMsg);<br>
-      continue;<br>
-    }<br>
-<br>
-    // <sym> may be redefined later in the link in .gnu.sgstubs<br>
-    symtab.cmseSymMap[name] = {acleSeSym, sym};<br>
-  }<br>
-<br>
-  // If this is an Arm CMSE secure app, replace references to entry symbol <sym><br>
-  // with its corresponding special symbol __acle_se_<sym>.<br>
-  parallelForEach(ctx.objectFiles, [&](InputFile *file) {<br>
-    MutableArrayRef<Symbol *> syms = file->getMutableSymbols();<br>
-    for (size_t i = 0, e = syms.size(); i != e; ++i) {<br>
-      StringRef symName = syms[i]->getName();<br>
-      if (symtab.cmseSymMap.count(symName))<br>
-        syms[i] = symtab.cmseSymMap[symName].acleSeSym;<br>
-    }<br>
-  });<br>
-}<br>
-<br>
-ArmCmseSGSection::ArmCmseSGSection()<br>
-    : SyntheticSection(llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_EXECINSTR,<br>
-                       llvm::ELF::SHT_PROGBITS,<br>
-                       /*alignment=*/32, ".gnu.sgstubs") {<br>
-  entsize = ACLESESYM_SIZE;<br>
-  // The range of addresses used in the CMSE import library should be fixed.<br>
-  for (auto &[_, sym] : symtab.cmseImportLib) {<br>
-    if (impLibMaxAddr <= sym->value)<br>
-      impLibMaxAddr = sym->value + sym->size;<br>
-  }<br>
-  if (symtab.cmseSymMap.empty())<br>
-    return;<br>
-  addMappingSymbol();<br>
-  for (auto &[_, entryFunc] : symtab.cmseSymMap)<br>
-    addSGVeneer(cast<Defined>(entryFunc.acleSeSym),<br>
-                cast<Defined>(entryFunc.sym));<br>
-  for (auto &[_, sym] : symtab.cmseImportLib) {<br>
-    if (!symtab.inCMSEOutImpLib.count(sym->getName()))<br>
-      warn("entry function '" + sym->getName() +<br>
-           "' from CMSE import library is not present in secure application");<br>
-  }<br>
-<br>
-  if (!symtab.cmseImportLib.empty() && config->cmseOutputLib.empty()) {<br>
-    for (auto &[_, entryFunc] : symtab.cmseSymMap) {<br>
-      Symbol *sym = entryFunc.sym;<br>
-      if (!symtab.inCMSEOutImpLib.count(sym->getName()))<br>
-        warn("new entry function '" + sym->getName() +<br>
-             "' introduced but no output import library specified");<br>
-    }<br>
-  }<br>
-}<br>
-<br>
-void ArmCmseSGSection::addSGVeneer(Symbol *acleSeSym, Symbol *sym) {<br>
-  entries.emplace_back(acleSeSym, sym);<br>
-  if (symtab.cmseImportLib.count(sym->getName()))<br>
-    symtab.inCMSEOutImpLib[sym->getName()] = true;<br>
-  // Symbol addresses <br>
diff erent, nothing to do.<br>
-  if (acleSeSym->file != sym->file ||<br>
-      cast<Defined>(*acleSeSym).value != cast<Defined>(*sym).value)<br>
-    return;<br>
-  // Only secure symbols with values equal to that of it's non-secure<br>
-  // counterpart needs to be in the .gnu.sgstubs section.<br>
-  ArmCmseSGVeneer *ss = nullptr;<br>
-  if (symtab.cmseImportLib.count(sym->getName())) {<br>
-    Defined *impSym = symtab.cmseImportLib[sym->getName()];<br>
-    ss = make<ArmCmseSGVeneer>(sym, acleSeSym, impSym->value);<br>
-  } else {<br>
-    ss = make<ArmCmseSGVeneer>(sym, acleSeSym);<br>
-    ++newEntries;<br>
-  }<br>
-  ss->parent = this;<br>
-  sgSections.emplace_back(ss);<br>
-}<br>
-<br>
-void ArmCmseSGSection::writeTo(uint8_t *buf) {<br>
-  for (ArmCmseSGVeneer *s : sgSections)<br>
-    s->writeTo(buf + s->outSecOff - getVA());<br>
-}<br>
-<br>
-void ArmCmseSGSection::addMappingSymbol() {<br>
-  addSyntheticLocal("$t", STT_NOTYPE, /*off=*/0, /*size=*/0, *this);<br>
-}<br>
-<br>
-size_t ArmCmseSGSection::getSize() const {<br>
-  if (sgSections.empty())<br>
-    return (impLibMaxAddr ? impLibMaxAddr - getVA() : 0) + newEntries * entsize;<br>
-<br>
-  return entries.size() * entsize;<br>
-}<br>
-<br>
-void ArmCmseSGSection::finalizeContents() {<br>
-  if (sgSections.empty())<br>
-    return;<br>
-<br>
-  auto it =<br>
-      std::stable_partition(sgSections.begin(), sgSections.end(),<br>
-                            [](auto *i) { return i->getAddr().has_value(); });<br>
-  std::sort(sgSections.begin(), it, [](auto *a, auto *b) {<br>
-    return a->getAddr().value() < b->getAddr().value();<br>
-  });<br>
-<br>
-  // This is the partition of the veneers with fixed addresses.<br>
-  uint64_t addr = (*sgSections.begin())->getAddr().has_value()<br>
-                      ? (*sgSections.begin())->getAddr().value()<br>
-                      : getVA();<br>
-  // Check if the start address of '.gnu.sgstubs' correspond to the<br>
-  // linker-synthesized veneer with the lowest address.<br>
-  if ((getVA() & ~1) != (addr & ~1)) {<br>
-    error("start address of '.gnu.sgstubs' is <br>
diff erent from previous link");<br>
-    return;<br>
-  }<br>
-<br>
-  for (ArmCmseSGVeneer *s : sgSections) {<br>
-    if (!s->getAddr().has_value())<br>
-      break;<br>
-    s->outSecOff = s->getAddr().value() & ~1;<br>
-    Defined(s->file, StringRef(), s->sym->binding, s->sym->stOther,<br>
-            s->sym->type, (s->outSecOff - getVA()) | 1, entsize, this)<br>
-        .overwrite(*s->sym);<br>
-  }<br>
-  // This is the partition of veneers newly synthesized by the linker.<br>
-  size_t off = std::max(getVA(), impLibMaxAddr);<br>
-  for (ArmCmseSGVeneer *s : llvm::reverse(sgSections)) {<br>
-    if (s->getAddr().has_value())<br>
-      break;<br>
-    s->outSecOff = off & ~1;<br>
-    Defined(s->file, StringRef(), s->sym->binding, s->sym->stOther,<br>
-            s->sym->type, (s->outSecOff - getVA()) | 1, entsize, this)<br>
-        .overwrite(*s->sym);<br>
-    off += s->entsize;<br>
-  }<br>
-}<br>
-<br>
-void ArmCmseSGVeneer::writeTo(uint8_t *buf) {<br>
-  write16(buf + 0, 0xe97f); // SG<br>
-  write16(buf + 2, 0xe97f);<br>
-  write16(buf + 4, 0xf000); // B.W S<br>
-  write16(buf + 6, 0xb000);<br>
-  target->relocateNoSym(buf + 4, R_ARM_THM_JUMP24,<br>
-                        acleSeSym->getVA() - getVA() - 8);<br>
-}<br>
-<br>
-// Write the CMSE import library to disk.<br>
-// The CMSE import library is a relocatable object with only a symbol table.<br>
-// The symbols are copies of the (absolute) symbols of the secure gateways<br>
-// in the executable output by this link.<br>
-// See Arm® v8-M Security Extensions: Requirements on Development Tools<br>
-// <a href="https://developer.arm.com/documentation/ecm0359818/latest" rel="noreferrer" target="_blank">https://developer.arm.com/documentation/ecm0359818/latest</a><br>
-template <typename ELFT> void elf::writeARMCmseImportLib() {<br>
-  StringTableSection *shstrtab =<br>
-      make<StringTableSection>(".shstrtab", /*dynamic=*/false);<br>
-  StringTableSection *strtab =<br>
-      make<StringTableSection>(".strtab", /*dynamic=*/false);<br>
-  SymbolTableBaseSection *impSymTab = make<SymbolTableSection<ELFT>>(*strtab);<br>
-<br>
-  SmallVector<std::pair<OutputSection *, SyntheticSection *>, 0> osIsPairs;<br>
-  osIsPairs.emplace_back(make<OutputSection>(strtab->name, 0, 0), strtab);<br>
-  osIsPairs.emplace_back(make<OutputSection>(impSymTab->name, 0, 0), impSymTab);<br>
-  osIsPairs.emplace_back(make<OutputSection>(shstrtab->name, 0, 0), shstrtab);<br>
-<br>
-  std::sort(symtab.cmseSymMap.begin(), symtab.cmseSymMap.end(),<br>
-            [](const auto &a, const auto &b) -> bool {<br>
-              return a.second.sym->getVA() < b.second.sym->getVA();<br>
-            });<br>
-  // Copy the secure gateway entry symbols to the import library symbol table.<br>
-  for (auto &p : symtab.cmseSymMap) {<br>
-    Defined *d = cast<Defined>(p.second.sym);<br>
-    impSymTab->addSymbol(makeDefined(nullptr, d->getName(), d->computeBinding(),<br>
-                                     /*stOther=*/0, STT_FUNC, d->getVA(),<br>
-                                     d->getSize(), nullptr));<br>
-  }<br>
-<br>
-  size_t idx = 0;<br>
-  uint64_t off = sizeof(typename ELFT::Ehdr);<br>
-  for (auto &[osec, isec] : osIsPairs) {<br>
-    osec->sectionIndex = ++idx;<br>
-    osec->recordSection(isec);<br>
-    osec->finalizeInputSections();<br>
-    osec->shName = shstrtab->addString(osec->name);<br>
-    osec->size = isec->getSize();<br>
-    isec->finalizeContents();<br>
-    osec->offset = alignToPowerOf2(off, osec->addralign);<br>
-    off = osec->offset + osec->size;<br>
-  }<br>
-<br>
-  const uint64_t sectionHeaderOff = alignToPowerOf2(off, config->wordsize);<br>
-  const auto shnum = osIsPairs.size() + 1;<br>
-  const uint64_t fileSize =<br>
-      sectionHeaderOff + shnum * sizeof(typename ELFT::Shdr);<br>
-  const unsigned flags =<br>
-      config->mmapOutputFile ? 0 : (unsigned)FileOutputBuffer::F_no_mmap;<br>
-  unlinkAsync(config->cmseOutputLib);<br>
-  Expected<std::unique_ptr<FileOutputBuffer>> bufferOrErr =<br>
-      FileOutputBuffer::create(config->cmseOutputLib, fileSize, flags);<br>
-  if (!bufferOrErr) {<br>
-    error("failed to open " + config->cmseOutputLib + ": " +<br>
-          llvm::toString(bufferOrErr.takeError()));<br>
-    return;<br>
-  }<br>
-<br>
-  // Write the ELF Header<br>
-  std::unique_ptr<FileOutputBuffer> &buffer = *bufferOrErr;<br>
-  uint8_t *const buf = buffer->getBufferStart();<br>
-  memcpy(buf, "\177ELF", 4);<br>
-  auto *eHdr = reinterpret_cast<typename ELFT::Ehdr *>(buf);<br>
-  eHdr->e_type = ET_REL;<br>
-  eHdr->e_entry = 0;<br>
-  eHdr->e_shoff = sectionHeaderOff;<br>
-  eHdr->e_ident[EI_CLASS] = ELFCLASS32;<br>
-  eHdr->e_ident[EI_DATA] = config->isLE ? ELFDATA2LSB : ELFDATA2MSB;<br>
-  eHdr->e_ident[EI_VERSION] = EV_CURRENT;<br>
-  eHdr->e_ident[EI_OSABI] = config->osabi;<br>
-  eHdr->e_ident[EI_ABIVERSION] = 0;<br>
-  eHdr->e_machine = EM_ARM;<br>
-  eHdr->e_version = EV_CURRENT;<br>
-  eHdr->e_flags = config->eflags;<br>
-  eHdr->e_ehsize = sizeof(typename ELFT::Ehdr);<br>
-  eHdr->e_phnum = 0;<br>
-  eHdr->e_shentsize = sizeof(typename ELFT::Shdr);<br>
-  eHdr->e_phoff = 0;<br>
-  eHdr->e_phentsize = 0;<br>
-  eHdr->e_shnum = shnum;<br>
-  eHdr->e_shstrndx = shstrtab->getParent()->sectionIndex;<br>
-<br>
-  // Write the section header table.<br>
-  auto *sHdrs = reinterpret_cast<typename ELFT::Shdr *>(buf + eHdr->e_shoff);<br>
-  for (auto &[osec, _] : osIsPairs)<br>
-    osec->template writeHeaderTo<ELFT>(++sHdrs);<br>
-<br>
-  // Write section contents to a mmap'ed file.<br>
-  {<br>
-    parallel::TaskGroup tg;<br>
-    for (auto &[osec, _] : osIsPairs)<br>
-      osec->template writeTo<ELFT>(buf + osec->offset, tg);<br>
-  }<br>
-<br>
-  if (auto e = buffer->commit())<br>
-    fatal("failed to write output '" + buffer->getPath() +<br>
-          "': " + toString(std::move(e)));<br>
-}<br>
-<br>
 TargetInfo *elf::getARMTargetInfo() {<br>
   static ARM target;<br>
   return &target;<br>
 }<br>
<br>
-template void elf::writeARMCmseImportLib<ELF32LE>();<br>
-template void elf::writeARMCmseImportLib<ELF32BE>();<br>
-template void elf::writeARMCmseImportLib<ELF64LE>();<br>
-template void elf::writeARMCmseImportLib<ELF64BE>();<br>
-<br>
-template void ObjFile<ELF32LE>::importCmseSymbols();<br>
-template void ObjFile<ELF32BE>::importCmseSymbols();<br>
-template void ObjFile<ELF64LE>::importCmseSymbols();<br>
-template void ObjFile<ELF64BE>::importCmseSymbols();<br>
<br>
diff  --git a/lld/ELF/Config.h b/lld/ELF/Config.h<br>
index 699c9d31e9433..956530098c0f1 100644<br>
--- a/lld/ELF/Config.h<br>
+++ b/lld/ELF/Config.h<br>
@@ -129,7 +129,6 @@ class LinkerDriver {<br>
<br>
   std::unique_ptr<BitcodeCompiler> lto;<br>
   std::vector<InputFile *> files;<br>
-  std::optional<InputFile *> armCmseImpLib;<br>
<br>
 public:<br>
   SmallVector<std::pair<StringRef, unsigned>, 0> archiveFiles;<br>
@@ -174,8 +173,6 @@ struct Config {<br>
   llvm::StringRef thinLTOCacheDir;<br>
   llvm::StringRef thinLTOIndexOnlyArg;<br>
   llvm::StringRef whyExtract;<br>
-  llvm::StringRef cmseInputLib;<br>
-  llvm::StringRef cmseOutputLib;<br>
   StringRef zBtiReport = "none";<br>
   StringRef zCetReport = "none";<br>
   llvm::StringRef ltoBasicBlockSections;<br>
@@ -198,13 +195,11 @@ struct Config {<br>
   llvm::MapVector<std::pair<const InputSectionBase *, const InputSectionBase *>,<br>
                   uint64_t><br>
       callGraphProfile;<br>
-  bool cmseImplib = false;<br>
   bool allowMultipleDefinition;<br>
   bool androidPackDynRelocs = false;<br>
   bool armHasBlx = false;<br>
   bool armHasMovtMovw = false;<br>
   bool armJ1J2BranchEncoding = false;<br>
-  bool armCMSESupport = false;<br>
   bool asNeeded = false;<br>
   BsymbolicKind bsymbolic = BsymbolicKind::None;<br>
   bool callGraphProfileSort;<br>
<br>
diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp<br>
index 2dbc2f24bc179..4eb10fc3c91e1 100644<br>
--- a/lld/ELF/Driver.cpp<br>
+++ b/lld/ELF/Driver.cpp<br>
@@ -345,22 +345,6 @@ static void checkOptions() {<br>
   if (config->emachine == EM_MIPS && config->gnuHash)<br>
     error("the .gnu.hash section is not compatible with the MIPS target");<br>
<br>
-  if (config->emachine == EM_ARM) {<br>
-    if (!config->cmseImplib) {<br>
-      if (!config->cmseInputLib.empty())<br>
-        error("--in-implib may not be used without --cmse-implib");<br>
-      if (!config->cmseOutputLib.empty())<br>
-        error("--out-implib may not be used without --cmse-implib");<br>
-    }<br>
-  } else {<br>
-    if (config->cmseImplib)<br>
-      error("--cmse-implib is only supported on ARM targets");<br>
-    if (!config->cmseInputLib.empty())<br>
-      error("--in-implib is only supported on ARM targets");<br>
-    if (!config->cmseOutputLib.empty())<br>
-      error("--out-implib is only supported on ARM targets");<br>
-  }<br>
-<br>
   if (config->fixCortexA53Errata843419 && config->emachine != EM_AARCH64)<br>
     error("--fix-cortex-a53-843419 is only supported on AArch64 targets");<br>
<br>
@@ -1177,9 +1161,6 @@ static void readConfigs(opt::InputArgList &args) {<br>
   config->fini = args.getLastArgValue(OPT_fini, "_fini");<br>
   config->fixCortexA53Errata843419 = args.hasArg(OPT_fix_cortex_a53_843419) &&<br>
                                      !args.hasArg(OPT_relocatable);<br>
-  config->cmseImplib = args.hasArg(OPT_cmse_implib);<br>
-  config->cmseInputLib = args.getLastArgValue(OPT_in_implib);<br>
-  config->cmseOutputLib = args.getLastArgValue(OPT_out_implib);<br>
   config->fixCortexA8 =<br>
       args.hasArg(OPT_fix_cortex_a8) && !args.hasArg(OPT_relocatable);<br>
   config->fortranCommon =<br>
@@ -1757,12 +1738,6 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {<br>
         files.back()->justSymbols = true;<br>
       }<br>
       break;<br>
-    case OPT_in_implib:<br>
-      if (armCmseImpLib)<br>
-        error("multiple CMSE import libraries not supported");<br>
-      else if (std::optional<MemoryBufferRef> mb = readFile(arg->getValue()))<br>
-        armCmseImpLib = createObjFile(*mb);<br>
-      break;<br>
     case OPT_start_group:<br>
       if (InputFile::isInGroup)<br>
         error("nested --start-group");<br>
@@ -2642,8 +2617,6 @@ void LinkerDriver::link(opt::InputArgList &args) {<br>
       llvm::TimeTraceScope timeScope("Parse input files", files[i]->getName());<br>
       parseFile(files[i]);<br>
     }<br>
-    if (armCmseImpLib)<br>
-      parseArmCMSEImportLib(*armCmseImpLib);<br>
   }<br>
<br>
   // Now that we have every file, we can decide if we will need a<br>
@@ -2808,9 +2781,6 @@ void LinkerDriver::link(opt::InputArgList &args) {<br>
   if (args.hasArg(OPT_exclude_libs))<br>
     excludeLibs(args);<br>
<br>
-  // Record [__acle_se_<sym>, <sym>] pairs for later processing.<br>
-  processArmCmseSymbols();<br>
-<br>
   // Apply symbol renames for --wrap and combine foo@v1 and foo@@v1.<br>
   redirectSymbols(wrapped);<br>
<br>
<br>
diff  --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp<br>
index 7c50291352190..5f24af5a9c6f5 100644<br>
--- a/lld/ELF/InputFiles.cpp<br>
+++ b/lld/ELF/InputFiles.cpp<br>
@@ -177,15 +177,6 @@ static void updateSupportedARMFeatures(const ARMAttributeParser &attributes) {<br>
       config->armHasMovtMovw = true;<br>
     break;<br>
   }<br>
-<br>
-  // Only ARMv8-M or later architectures have CMSE support.<br>
-  std::optional<unsigned> profile =<br>
-      attributes.getAttributeValue(ARMBuildAttrs::CPU_arch_profile);<br>
-  if (!profile)<br>
-    return;<br>
-  if (arch >= ARMBuildAttrs::CPUArch::v8_M_Base &&<br>
-      profile == ARMBuildAttrs::MicroControllerProfile)<br>
-    config->armCMSESupport = true;<br>
 }<br>
<br>
 InputFile::InputFile(Kind k, MemoryBufferRef m)<br>
@@ -326,14 +317,6 @@ template <class ELFT> static void doParseFile(InputFile *file) {<br>
 // Add symbols in File to the symbol table.<br>
 void elf::parseFile(InputFile *file) { invokeELFT(doParseFile, file); }<br>
<br>
-template <class ELFT> static void doParseArmCMSEImportLib(InputFile *file) {<br>
-  cast<ObjFile<ELFT>>(file)->importCmseSymbols();<br>
-}<br>
-<br>
-void elf::parseArmCMSEImportLib(InputFile *file) {<br>
-  invokeELFT(doParseArmCMSEImportLib, file);<br>
-}<br>
-<br>
 // Concatenates arguments to construct a string representing an error location.<br>
 static std::string createFileLineMsg(StringRef path, unsigned line) {<br>
   std::string filename = std::string(path::filename(path));<br>
@@ -1048,8 +1031,8 @@ InputSectionBase *ObjFile<ELFT>::createInputSection(uint32_t idx,<br>
   return makeThreadLocal<InputSection>(*this, sec, name);<br>
 }<br>
<br>
-// Initialize symbols. symbols is a parallel array to the corresponding ELF<br>
-// symbol table.<br>
+// Initialize this->Symbols. this->Symbols is a parallel array as<br>
+// its corresponding ELF symbol table.<br>
 template <class ELFT><br>
 void ObjFile<ELFT>::initializeSymbols(const object::ELFFile<ELFT> &obj) {<br>
   ArrayRef<Elf_Sym> eSyms = this->getELFSyms<ELFT>();<br>
<br>
diff  --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h<br>
index cc658bdc23198..2ee15e89347ab 100644<br>
--- a/lld/ELF/InputFiles.h<br>
+++ b/lld/ELF/InputFiles.h<br>
@@ -48,8 +48,6 @@ std::optional<MemoryBufferRef> readFile(StringRef path);<br>
 // Add symbols in File to the symbol table.<br>
 void parseFile(InputFile *file);<br>
<br>
-void parseArmCMSEImportLib(InputFile *file);<br>
-<br>
 // The root class of input files.<br>
 class InputFile {<br>
 protected:<br>
@@ -90,12 +88,6 @@ class InputFile {<br>
     return {symbols.get(), numSymbols};<br>
   }<br>
<br>
-  MutableArrayRef<Symbol *> getMutableSymbols() {<br>
-    assert(fileKind == BinaryKind || fileKind == ObjKind ||<br>
-           fileKind == BitcodeKind);<br>
-    return {symbols.get(), numSymbols};<br>
-  }<br>
-<br>
   // Get filename to use for linker script processing.<br>
   StringRef getNameForScript() const;<br>
<br>
@@ -288,8 +280,6 @@ template <class ELFT> class ObjFile : public ELFFileBase {<br>
<br>
   void initSectionsAndLocalSyms(bool ignoreComdats);<br>
   void postParse();<br>
-  void importCmseSymbols();<br>
-  void redirectCmseSymbols();<br>
<br>
 private:<br>
   void initializeSections(bool ignoreComdats,<br>
<br>
diff  --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp<br>
index 28e9f0461b2d6..777f1f2f85f95 100644<br>
--- a/lld/ELF/LinkerScript.cpp<br>
+++ b/lld/ELF/LinkerScript.cpp<br>
@@ -896,15 +896,6 @@ void LinkerScript::diagnoseOrphanHandling() const {<br>
   }<br>
 }<br>
<br>
-void LinkerScript::diagnoseMissingSGSectionAddress() const {<br>
-  if (!config->cmseImplib || !in.armCmseSGSection->isNeeded())<br>
-    return;<br>
-<br>
-  OutputSection *sec = findByName(sectionCommands, ".gnu.sgstubs");<br>
-  if (sec && !sec->addrExpr && !config->sectionStartMap.count(".gnu.sgstubs"))<br>
-    error("no address assigned to the veneers output section " + sec->name);<br>
-}<br>
-<br>
 // This function searches for a memory region to place the given output<br>
 // section in. If found, a pointer to the appropriate memory region is<br>
 // returned in the first member of the pair. Otherwise, a nullptr is returned.<br>
<br>
diff  --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h<br>
index 8b8320f9f18e0..ee0985ae94382 100644<br>
--- a/lld/ELF/LinkerScript.h<br>
+++ b/lld/ELF/LinkerScript.h<br>
@@ -318,7 +318,6 @@ class LinkerScript final {<br>
<br>
   void addOrphanSections();<br>
   void diagnoseOrphanHandling() const;<br>
-  void diagnoseMissingSGSectionAddress() const;<br>
   void adjustOutputSections();<br>
   void adjustSectionsAfterSorting();<br>
<br>
<br>
diff  --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp<br>
index 353c7ead55dfb..7db7d1c257d46 100644<br>
--- a/lld/ELF/MarkLive.cpp<br>
+++ b/lld/ELF/MarkLive.cpp<br>
@@ -230,10 +230,6 @@ template <class ELFT> void MarkLive<ELFT>::run() {<br>
     markSymbol(symtab.find(s));<br>
   for (StringRef s : script->referencedSymbols)<br>
     markSymbol(symtab.find(s));<br>
-  for (auto [symName, _] : symtab.cmseSymMap) {<br>
-    markSymbol(symtab.cmseSymMap[symName].sym);<br>
-    markSymbol(symtab.cmseSymMap[symName].acleSeSym);<br>
-  }<br>
<br>
   // Mark .eh_frame sections as live because there are usually no relocations<br>
   // that point to .eh_frames. Otherwise, the garbage collector would drop<br>
<br>
diff  --git a/lld/ELF/Options.td b/lld/ELF/Options.td<br>
index e9fbe232d8462..0c6884afe52d4 100644<br>
--- a/lld/ELF/Options.td<br>
+++ b/lld/ELF/Options.td<br>
@@ -80,18 +80,6 @@ defm split_stack_adjust_size<br>
<br>
 def O: JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">;<br>
<br>
-def cmse_implib: FF<"cmse-implib">,<br>
-  HelpText<"Make the output library to be a CMSE secure code import library">;<br>
-<br>
-defm in_implib: EEq<"in-implib",<br>
-    "Read an existing CMSE secure code import library and preserve entry function addresses in the "<br>
-    "resulting new CMSE secure code import library (optional when creating a CMSE secure image)">,<br>
-  MetaVarName<"<file>">;<br>
-<br>
-defm out_implib: EEq<"out-implib",<br>
-    "Output the CMSE secure code import library to <file> (required when creating a CMSE secure image)">,<br>
-  MetaVarName<"<file>">;<br>
-<br>
 defm Tbss: Eq<"Tbss", "Same as --section-start with .bss as the sectionname">;<br>
<br>
 defm Tdata: Eq<"Tdata", "Same as --section-start with .data as the sectionname">;<br>
<br>
diff  --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h<br>
index 37e31d2372963..9c93ae1876af0 100644<br>
--- a/lld/ELF/SymbolTable.h<br>
+++ b/lld/ELF/SymbolTable.h<br>
@@ -19,11 +19,6 @@ namespace lld::elf {<br>
 class InputFile;<br>
 class SharedFile;<br>
<br>
-struct ArmCmseEntryFunction {<br>
-  Symbol *acleSeSym;<br>
-  Symbol *sym;<br>
-};<br>
-<br>
 // SymbolTable is a bucket of all known symbols, including defined,<br>
 // undefined, or lazy symbols (the last one is symbols in archive<br>
 // files whose archive members are not yet loaded).<br>
@@ -65,18 +60,6 @@ class SymbolTable {<br>
   // is used to uniquify them.<br>
   llvm::DenseMap<llvm::CachedHashStringRef, const InputFile *> comdatGroups;<br>
<br>
-  // The Map of __acle_se_<sym>, <sym> pairs found in the input objects.<br>
-  // Key is the <sym> name.<br>
-  llvm::SmallMapVector<StringRef, ArmCmseEntryFunction, 1> cmseSymMap;<br>
-<br>
-  // Map of symbols defined in the Arm CMSE import library. The linker must<br>
-  // preserve the addresses in the output objects.<br>
-  llvm::StringMap<Defined *> cmseImportLib;<br>
-<br>
-  // True if <sym> from the input Arm CMSE import library is written to the<br>
-  // output Arm CMSE import library.<br>
-  llvm::StringMap<bool> inCMSEOutImpLib;<br>
-<br>
 private:<br>
   SmallVector<Symbol *, 0> findByVersion(SymbolVersion ver);<br>
   SmallVector<Symbol *, 0> findAllByVersion(SymbolVersion ver,<br>
<br>
diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp<br>
index 678b130e9ef63..48f30123dcc00 100644<br>
--- a/lld/ELF/SyntheticSections.cpp<br>
+++ b/lld/ELF/SyntheticSections.cpp<br>
@@ -3828,7 +3828,6 @@ void InStruct::reset() {<br>
   got.reset();<br>
   gotPlt.reset();<br>
   igotPlt.reset();<br>
-  armCmseSGSection.reset();<br>
   ppc64LongBranchTarget.reset();<br>
   mipsAbiFlags.reset();<br>
   mipsGot.reset();<br>
<br>
diff  --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h<br>
index de07aee9c98cc..a2554c7fd4a73 100644<br>
--- a/lld/ELF/SyntheticSections.h<br>
+++ b/lld/ELF/SyntheticSections.h<br>
@@ -1143,51 +1143,6 @@ class ThunkSection final : public SyntheticSection {<br>
   size_t size = 0;<br>
 };<br>
<br>
-// Cortex-M Security Extensions. Prefix for functions that should be exported<br>
-// for the non-secure world.<br>
-const char ACLESESYM_PREFIX[] = "__acle_se_";<br>
-const int ACLESESYM_SIZE = 8;<br>
-<br>
-class ArmCmseSGVeneer : public SyntheticSection {<br>
-public:<br>
-  ArmCmseSGVeneer(Symbol *sym, Symbol *acleSeSym,<br>
-                  std::optional<uint64_t> addr = std::nullopt)<br>
-      : SyntheticSection(llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_EXECINSTR,<br>
-                         llvm::ELF::SHT_PROGBITS,<br>
-                         /*alignment=*/32, ".gnu.sgstubs"),<br>
-        sym(sym), acleSeSym(acleSeSym), entAddr{addr} {<br>
-    entsize = ACLESESYM_SIZE;<br>
-  }<br>
-<br>
-  void writeTo(uint8_t *buf) override;<br>
-  size_t getSize() const override { return entsize; };<br>
-  const std::optional<uint64_t> getAddr() const { return entAddr; };<br>
-<br>
-  Symbol *sym;<br>
-  Symbol *acleSeSym;<br>
-<br>
-private:<br>
-  const std::optional<uint64_t> entAddr;<br>
-};<br>
-<br>
-class ArmCmseSGSection : public SyntheticSection {<br>
-public:<br>
-  ArmCmseSGSection();<br>
-  bool isNeeded() const override { return !entries.empty(); }<br>
-  size_t getSize() const override;<br>
-  void writeTo(uint8_t *buf) override;<br>
-  void addSGVeneer(Symbol *sym, Symbol *ext_sym);<br>
-  void addMappingSymbol();<br>
-  void finalizeContents() override;<br>
-  void exportEntries(SymbolTableBaseSection *symTab);<br>
-  uint64_t impLibMaxAddr = 0;<br>
-<br>
-private:<br>
-  SmallVector<std::pair<Symbol *, Symbol *>, 0> entries;<br>
-  SmallVector<ArmCmseSGVeneer *, 0> sgSections;<br>
-  uint64_t newEntries = 0;<br>
-};<br>
-<br>
 // Used to compute outSecOff of .got2 in each object file. This is needed to<br>
 // synthesize PLT entries for PPC32 Secure PLT ABI.<br>
 class PPC32Got2Section final : public SyntheticSection {<br>
@@ -1324,7 +1279,6 @@ struct InStruct {<br>
   std::unique_ptr<GotSection> got;<br>
   std::unique_ptr<GotPltSection> gotPlt;<br>
   std::unique_ptr<IgotPltSection> igotPlt;<br>
-  std::unique_ptr<SyntheticSection> armCmseSGSection;<br>
   std::unique_ptr<PPC64LongBranchTargetSection> ppc64LongBranchTarget;<br>
   std::unique_ptr<SyntheticSection> mipsAbiFlags;<br>
   std::unique_ptr<MipsGotSection> mipsGot;<br>
<br>
diff  --git a/lld/ELF/Target.h b/lld/ELF/Target.h<br>
index cec105f967a90..59534ab3256df 100644<br>
--- a/lld/ELF/Target.h<br>
+++ b/lld/ELF/Target.h<br>
@@ -200,8 +200,6 @@ static inline std::string getErrorLocation(const uint8_t *loc) {<br>
   return getErrorPlace(loc).loc;<br>
 }<br>
<br>
-void processArmCmseSymbols();<br>
-<br>
 void writePPC32GlinkSection(uint8_t *buf, size_t numEntries);<br>
<br>
 unsigned getPPCDFormOp(unsigned secondaryOp);<br>
@@ -223,7 +221,6 @@ void writePrefixedInstruction(uint8_t *loc, uint64_t insn);<br>
 void addPPC64SaveRestore();<br>
 uint64_t getPPC64TocBase();<br>
 uint64_t getAArch64Page(uint64_t expr);<br>
-template <typename ELFT> void writeARMCmseImportLib();<br>
 void riscvFinalizeRelax(int passes);<br>
 void mergeRISCVAttributesSections();<br>
<br>
<br>
diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp<br>
index 361e0ab33f7cf..3630b199714da 100644<br>
--- a/lld/ELF/Writer.cpp<br>
+++ b/lld/ELF/Writer.cpp<br>
@@ -454,11 +454,6 @@ template <class ELFT> void elf::createSyntheticSections() {<br>
   in.igotPlt = std::make_unique<IgotPltSection>();<br>
   add(*in.igotPlt);<br>
<br>
-  if (config->emachine == EM_ARM) {<br>
-    in.armCmseSGSection = std::make_unique<ArmCmseSGSection>();<br>
-    add(*in.armCmseSGSection);<br>
-  }<br>
-<br>
   // _GLOBAL_OFFSET_TABLE_ is defined relative to either .got.plt or .got. Treat<br>
   // it as a relocation and ensure the referenced section is created.<br>
   if (ElfSym::globalOffsetTable && config->emachine != EM_MIPS) {<br>
@@ -600,9 +595,6 @@ template <class ELFT> void Writer<ELFT>::run() {<br>
     if (auto e = buffer->commit())<br>
       fatal("failed to write output '" + buffer->getPath() +<br>
             "': " + toString(std::move(e)));<br>
-<br>
-    if (!config->cmseOutputLib.empty())<br>
-      writeARMCmseImportLib<ELFT>();<br>
   }<br>
 }<br>
<br>
@@ -1991,7 +1983,6 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {<br>
<br>
   removeUnusedSyntheticSections();<br>
   script->diagnoseOrphanHandling();<br>
-  script->diagnoseMissingSGSectionAddress();<br>
<br>
   sortSections();<br>
<br>
@@ -2143,7 +2134,6 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {<br>
     // static symbol table.<br>
     finalizeSynthetic(in.symTab.get());<br>
     finalizeSynthetic(in.ppc64LongBranchTarget.get());<br>
-    finalizeSynthetic(in.armCmseSGSection.get());<br>
   }<br>
<br>
   // Relaxation to delete inter-basic block jumps created by basic block<br>
<br>
diff  --git a/lld/test/ELF/Inputs/arm-cmse-macros.s b/lld/test/ELF/Inputs/arm-cmse-macros.s<br>
deleted file mode 100644<br>
index bfa3dcf33258e..0000000000000<br>
--- a/lld/test/ELF/Inputs/arm-cmse-macros.s<br>
+++ /dev/null<br>
@@ -1,32 +0,0 @@<br>
-/// Because the addresses of __acle_se_\sym_name and \sym_name are equal,<br>
-/// the linker creates a secure gateway in ".gnu.sgstubs".<br>
-.macro cmse_veneer sym_name, sym_type, sym_binding, acle_sym_type, acle_sym_binding<br>
-.align  2<br>
-.\sym_binding  \sym_name<br>
-.\acle_sym_binding  __acle_se_\sym_name<br>
-.type  \sym_name, %\sym_type<br>
-.type  __acle_se_\sym_name, %\acle_sym_type<br>
-\sym_name:<br>
-__acle_se_\sym_name:<br>
-  nop<br>
-.size  \sym_name, .-\sym_name<br>
-.size  __acle_se_\sym_name, .-__acle_se_\sym_name<br>
-.endm<br>
-<br>
-/// Because the addresses of __acle_se_\sym_name and \sym_name are not equal,<br>
-/// the linker considers that an inline secure gateway exists and does not<br>
-/// create one.<br>
-.macro cmse_no_veneer sym_name, sym_type, sym_binding, acle_sym_type, acle_sym_binding<br>
-.align  2<br>
-.\sym_binding  \sym_name<br>
-.\acle_sym_binding  __acle_se_\sym_name<br>
-.type  \sym_name, %\sym_type<br>
-.type  __acle_se_\sym_name, %\acle_sym_type<br>
-\sym_name:<br>
-       sg<br>
-  nop<br>
-__acle_se_\sym_name:<br>
-  nop<br>
-.size  \sym_name, .-\sym_name<br>
-.size  __acle_se_\sym_name, .-__acle_se_\sym_name<br>
-.endm<br>
<br>
diff  --git a/lld/test/ELF/aarch64-cmse.s b/lld/test/ELF/aarch64-cmse.s<br>
deleted file mode 100644<br>
index a360d482272d9..0000000000000<br>
--- a/lld/test/ELF/aarch64-cmse.s<br>
+++ /dev/null<br>
@@ -1,16 +0,0 @@<br>
-# REQUIRES: aarch64<br>
-# RUN: yaml2obj %s -o %t.o<br>
-# RUN: not ld.lld --cmse-implib %t.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR_CMSE_IMPLIB<br>
-# RUN: not ld.lld --in-implib=%t.o %t.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR_IN_IMPLIB<br>
-# RUN: not ld.lld --out-implib=out.lib %t.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR_OUT_IMPLIB<br>
-<br>
-# ERR_CMSE_IMPLIB: error: --cmse-implib is only supported on ARM targets<br>
-# ERR_IN_IMPLIB: error: --in-implib is only supported on ARM targets<br>
-# ERR_OUT_IMPLIB: error: --out-implib is only supported on ARM targets<br>
-<br>
-!ELF<br>
-FileHeader:<br>
-  Class:           ELFCLASS64<br>
-  Data:            ELFDATA2LSB<br>
-  Type:            ET_REL<br>
-  Machine:         EM_AARCH64<br>
<br>
diff  --git a/lld/test/ELF/arm-cmse-diagnostics.s b/lld/test/ELF/arm-cmse-diagnostics.s<br>
deleted file mode 100644<br>
index 579cc409ad1e2..0000000000000<br>
--- a/lld/test/ELF/arm-cmse-diagnostics.s<br>
+++ /dev/null<br>
@@ -1,281 +0,0 @@<br>
-// REQUIRES: arm<br>
-/// Test CMSE diagnostics.<br>
-<br>
-// RUN: rm -rf %t && split-file %s %t && cd %t<br>
-<br>
-/// Test diagnostics emitted during checks of the CMSE import library<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.base lib -o lib.o<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.base app -I %S/Inputs -o app.o<br>
-// RUN: llvm-objcopy --redefine-sym=entry7_duplicate=entry6_duplicate lib.o<br>
-// RUN: not ld.lld --cmse-implib --in-implib=lib.o app.o -o /dev/null 2>&1 | FileCheck %s --check-prefixes=ERR_IMPLIB<br>
-// RUN: not ld.lld --cmse-implib --in-implib=lib.o --in-implib=lib.o app.o -o /dev/null 2>&1 | FileCheck %s --check-prefixes=ERR_MULT_INIMPLIB<br>
-// RUN: not ld.lld --in-implib=lib.o app.o -o /dev/null 2>&1 | FileCheck %s --check-prefixes=ERR_IN_IMPLIB<br>
-// RUN: not ld.lld --out-implib=out.lib app.o -o /dev/null 2>&1 | FileCheck %s --check-prefixes=ERR_OUT_IMPLIB<br>
-// RUN: not ld.lld --out-implib=out.lib --in-implib=lib.o app.o -o /dev/null 2>&1 | FileCheck %s --check-prefixes=ERR_IN_IMPLIB,ERR_OUT_IMPLIB<br>
-<br>
-// ERR_IMPLIB: error: CMSE symbol 'entry_not_external' in import library '{{.*}}' is not global<br>
-// ERR_IMPLIB: error: CMSE symbol 'entry_not_absolute' in import library '{{.*}}' is not absolute<br>
-// ERR_IMPLIB: error: CMSE symbol 'entry_not_function' in import library '{{.*}}' is not a Thumb function definition<br>
-// ERR_IMPLIB: error: CMSE symbol 'entry_not_thumb' in import library '{{.*}}' is not a Thumb function definition<br>
-// ERR_IMPLIB: warning: CMSE symbol 'entry5_incorrect_size' in import library '{{.*}}' does not have correct size of 8 bytes<br>
-// ERR_IMPLIB: error: CMSE symbol 'entry6_duplicate' is multiply defined in import library '{{.*}}'<br>
-// ERR_MULT_INIMPLIB: error: multiple CMSE import libraries not supported<br>
-// ERR_IN_IMPLIB: error: --in-implib may not be used without --cmse-implib<br>
-// ERR_OUT_IMPLIB: error: --out-implib may not be used without --cmse-implib<br>
-<br>
-/// CMSE Only supported by ARMv8-M architecture or later.<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv8m.base app -I %S/Inputs -o app1.o<br>
-// RUN: ld.lld --cmse-implib -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app1 app1.o 2>&1 | FileCheck /dev/null --implicit-check-not=error:<br>
-<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv8m.main app -I %S/Inputs -o app2.o<br>
-// RUN: ld.lld --cmse-implib -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app2 app2.o 2>&1 | FileCheck /dev/null --implicit-check-not=error:<br>
-<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv8.1m.main app -I %S/Inputs -o app3.o<br>
-// RUN: ld.lld --cmse-implib -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app3 app3.o 2>&1 | FileCheck /dev/null --implicit-check-not=error:<br>
-<br>
-/// Expect errors for other architectures.<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv9a app -I %S/Inputs -o app4.o<br>
-// RUN: not ld.lld --cmse-implib -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app4 app4.o 2>&1 | FileCheck %s --check-prefixes=ERR_ARCH<br>
-<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7-m app -I %S/Inputs -o app5.o<br>
-// RUN: not ld.lld --cmse-implib -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app5 app5.o 2>&1 | FileCheck %s --check-prefixes=ERR_ARCH<br>
-<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv8-m app -I %S/Inputs -o app6.o<br>
-// RUN: not ld.lld --cmse-implib -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app6 app6.o 2>&1 | FileCheck %s --check-prefixes=ERR_ARCH<br>
-<br>
-/// Invalid triple defaults to v4T. Error.<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumb app -I %S/Inputs -o app7.o<br>
-// RUN: not ld.lld --cmse-implib -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app7 app7.o  2>&1 | FileCheck %s --check-prefixes=ERR_ARCH<br>
-<br>
-/// No build attributes. Error.<br>
-// RUN: llvm-mc -filetype=obj -triple=thumb app -I %S/Inputs -o app8.o<br>
-// RUN: not ld.lld --cmse-implib -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o app8 app8.o  2>&1 | FileCheck %s --check-prefixes=ERR_ARCH<br>
-<br>
-// ERR_ARCH: CMSE is only supported by ARMv8-M architecture or later<br>
-<br>
-/// Test that the linker diagnoses cases where the linker synthesized veneer addresses<br>
-/// specified by the CMSE input library cannot be placed at the .gnu.sgstubs section address.<br>
-<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.main app -I %S/Inputs -o 1.o<br>
-/// Create a CMSE import library with a secure gateway veneer at 0x10000<br>
-// RUN: ld.lld --cmse-implib --section-start .gnu.sgstubs=0x10000 1.o -o 1 --out-implib=1.lib 2>&1 | FileCheck /dev/null --implicit-check-not=error:<br>
-/// Create a new import library with the secure gateway veneer and .gnu.sgstubs specified at the same address<br>
-// RUN: ld.lld --cmse-implib --section-start .gnu.sgstubs=0x10000 1.o -o 2 --out-implib=2.lib --in-implib=1.lib 2>&1 | FileCheck /dev/null --implicit-check-not=error:<br>
-/// Create a new import library with the secure gateway veneer specified at a same address but .gnu.sgstubs at a higher address.<br>
-// RUN: not ld.lld --cmse-implib --section-start .gnu.sgstubs=0x11000 1.o -o 3 --out-implib=3.lib --in-implib=1.lib 2>&1 | FileCheck %s --check-prefixes=ERR_ADDR<br>
-/// Create a new import library with the secure gateway veneer specified at a same address but .gnu.sgstubs at a lower address.<br>
-// RUN: not ld.lld --cmse-implib --section-start .gnu.sgstubs=0x9000 1.o -o 4 --out-implib=4.lib --in-implib=1.lib 2>&1 | FileCheck %s --check-prefixes=ERR_ADDR<br>
-<br>
-// ERR_ADDR: error: start address of '.gnu.sgstubs' is <br>
diff erent from previous link<br>
-<br>
-/// Test that the address of .gnu.sgstubs can be specified via command line or linker script.<br>
-/// Test that the linker errors when the address of .gnu.sgstubs is not specified using either method.<br>
-<br>
-// RUN: ld.lld --cmse-implib -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 --script with_sgstubs.script 1.o -o 1 2>&1 | FileCheck /dev/null --implicit-check-not=error:<br>
-// RUN: ld.lld --cmse-implib -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 --script wout_sgstubs.script 1.o -o 2 2>&1 | FileCheck /dev/null --implicit-check-not=error:<br>
-// RUN: ld.lld --cmse-implib -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 1.o -o 3 2>&1 | FileCheck /dev/null --implicit-check-not=error:<br>
-// RUN: ld.lld --cmse-implib -Ttext=0x8000 --script with_sgstubs.script 1.o -o 4 2>&1 | FileCheck /dev/null --implicit-check-not=error:<br>
-// RUN: not ld.lld --cmse-implib -Ttext=0x8000 --script wout_sgstubs.script 1.o -o 5 2>&1 | FileCheck %s --check-prefixes=ERR_NOADDR<br>
-<br>
-// RUN: llvm-readelf -S 1 | FileCheck %s --check-prefixes=ADDRCMDLINE<br>
-// RUN: llvm-readelf -S 2 | FileCheck %s --check-prefixes=ADDRCMDLINE<br>
-// RUN: llvm-readelf -S 3 | FileCheck %s --check-prefixes=ADDRCMDLINE<br>
-// RUN: llvm-readelf -S 4 | FileCheck %s --check-prefixes=ADDRLNKSCRIPT<br>
-<br>
-// ERR_NOADDR: error: no address assigned to the veneers output section .gnu.sgstubs<br>
-<br>
-///                       Name          Type         Address    Off   Size ES Flg Lk Inf Al<br>
-// ADDRCMDLINE:   .gnu.sgstubs      PROGBITS        00020000 020000 000008 08  AX  0   0 32<br>
-// ADDRLNKSCRIPT: .gnu.sgstubs      PROGBITS        00040000 040000 000008 08  AX  0   0 32<br>
-<br>
-/// Test diagnostics emitted during symbol attribute checks.<br>
-<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -I %S/Inputs --triple=thumbv8m.base symattr -o symattr.o<br>
-// RUN: not ld.lld --cmse-implib symattr.o -o /dev/null 2>&1 | FileCheck %s --check-prefixes=ERR_SYMATTR<br>
-<br>
-// ERR_SYMATTR-NOT: __acle_se_valid_{{.*}}<br>
-// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_1' is not a Thumb function definition<br>
-// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_2' is not a Thumb function definition<br>
-// ERR_SYMATTR: error: {{.*}}: cmse entry symbol 'invalid_3' is not a Thumb function definition<br>
-// ERR_SYMATTR: error: {{.*}}: cmse entry symbol 'invalid_4' is not a Thumb function definition<br>
-// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_5' detected, but no associated entry function definition 'invalid_5' with external linkage found<br>
-// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_6' detected, but no associated entry function definition 'invalid_6' with external linkage found<br>
-// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_7' is not a Thumb function definition<br>
-// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_8' detected, but no associated entry function definition 'invalid_8' with external linkage found<br>
-// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_9' cannot be an absolute symbol<br>
-// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_10' cannot be an absolute symbol<br>
-// ERR_SYMATTR: error: {{.*}}: cmse special symbol '__acle_se_invalid_11' is not a Thumb function definition<br>
-// ERR_SYMATTR: error: {{.*}}: cmse entry symbol 'invalid_12' is not a Thumb function definition<br>
-<br>
-/// Test diagnostics emitted when a symbol is removed from a later version of the import library.<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -I %S/Inputs --triple=thumbv8m.base libv1 -o libv1.o<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -I %S/Inputs --triple=thumbv8m.base libv2 -o libv2.o<br>
-// RUN: ld.lld -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 --cmse-implib libv1.o --out-implib=libv1.lib -o /dev/null<br>
-// RUN: ld.lld -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 --cmse-implib libv2.o --in-implib=libv1.lib --out-implib=libv2.lib -o /dev/null 2>&1 | FileCheck %s --check-prefixes=WARN_MISSING<br>
-// RUN: ld.lld -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 --cmse-implib libv1.o --in-implib=libv2.lib -o /dev/null 2>&1 | FileCheck %s --check-prefixes=WARN_NEWENTRY<br>
-<br>
-// WARN_MISSING: warning: entry function 'foo' from CMSE import library is not present in secure application<br>
-// WARN_NEWENTRY: warning: new entry function 'foo' introduced but no output import library specified<br>
-<br>
-//--- with_sgstubs.script<br>
-SECTIONS {<br>
-  .text : { *(.text) }<br>
-  .gnu.sgstubs 0x40000 : { *(.gnu.sgstubs*) }<br>
-}<br>
-<br>
-//--- wout_sgstubs.script<br>
-SECTIONS {<br>
-  .text : { *(.text) }<br>
-}<br>
-<br>
-//--- app<br>
-  .include "arm-cmse-macros.s"<br>
-  .text<br>
-  .thumb<br>
-<br>
-cmse_veneer entry, function, global, function, global<br>
-<br>
-//--- lib<br>
-    .text<br>
-    .thumb<br>
-<br>
-/// Symbol not absolute.<br>
-    .global entry_not_absolute<br>
-    .type entry_not_absolute, STT_FUNC<br>
-    .thumb_func<br>
-entry_not_absolute:<br>
-    .size entry_not_absolute, 8<br>
-<br>
-/// Symbol not global or weak.<br>
-    .local entry_not_external<br>
-    .type entry_not_external, STT_FUNC<br>
-entry_not_external=0x1001<br>
-    .size entry_not_external, 8<br>
-<br>
-/// Symbol not the function type.<br>
-    .global entry_not_function<br>
-    .type entry_not_function, STT_NOTYPE<br>
-entry_not_function=0x1001<br>
-    .size entry_not_function, 8<br>
-<br>
-/// Symbol not a Thumb code symbol.<br>
-    .global entry_not_thumb<br>
-    .type entry_not_thumb, STT_FUNC<br>
-entry_not_thumb=0x1000<br>
-    .size entry_not_thumb, 8<br>
-<br>
-/// Symbol with incorrect size.<br>
-    .global entry5_incorrect_size<br>
-    .type entry5_incorrect_size, STT_FUNC<br>
-entry5_incorrect_size=0x1009<br>
-    .size entry5_incorrect_size, 6<br>
-<br>
-/// Duplicate symbols.<br>
-    .global entry6_duplicate<br>
-    .type entry6_duplicate, STT_FUNC<br>
-entry6_duplicate=0x1001<br>
-    .size entry6_duplicate, 8<br>
-<br>
-/// entry7_duplicate gets renamed to entry6_duplicate by llvm-objcopy.<br>
-    .global entry7_duplicate<br>
-    .type entry7_duplicate, STT_FUNC<br>
-entry7_duplicate=0x1009<br>
-    .size entry7_duplicate, 8<br>
-<br>
-//--- symattr<br>
-.include "arm-cmse-macros.s"<br>
-<br>
-  .text<br>
-  .thumb<br>
-<br>
-/// Valid sequences<br>
-/// both sym and __acle_se_sym should be global or weak Thumb code symbols.<br>
-  cmse_veneer valid_1, function, global, function, global<br>
-  cmse_veneer valid_2, function,   weak, function,   weak<br>
-  cmse_veneer valid_3, function,   weak, function, global<br>
-  cmse_veneer valid_4, function, global, function,   weak<br>
-<br>
-/// Invalid sequences<br>
-/// __acle_se_sym is an object<br>
-  cmse_veneer invalid_1, function, global,   object, global<br>
-  cmse_veneer invalid_2, function, global,   object,   weak<br>
-/// sym is an object<br>
-  cmse_veneer invalid_3,   object, global, function, global<br>
-  cmse_veneer invalid_4,   object, global, function,   weak<br>
-/// sym is local<br>
-  cmse_veneer invalid_5, function,  local, function, global<br>
-  cmse_veneer invalid_6, function,  local, function,   weak<br>
-<br>
-/// __acle_se_invalid_7 not defined.<br>
-  .global invalid_7<br>
-       .type   invalid_7, %function<br>
-  .global __acle_se_invalid_7<br>
-  .thumb_func<br>
-invalid_7:<br>
-<br>
-/// invalid_8 not defined.<br>
-  .global __acle_se_invalid_8<br>
-  .thumb_func<br>
-__acle_se_invalid_8:<br>
-<br>
-// Absolute symbols with same values<br>
-  .global invalid_9<br>
-  .global __acle_se_invalid_9<br>
-       .type   __acle_se_invalid_9, %function<br>
-       .type   invalid_9, %function<br>
-__acle_se_invalid_9=0x1001<br>
-invalid_9=0x1001<br>
-       .size   invalid_9, 0<br>
-  .size __acle_se_invalid_9, 0<br>
-<br>
-// Absolute symbols with <br>
diff erent values<br>
-       .align 2<br>
-       .global __acle_se_invalid_10<br>
-       .global invalid_10<br>
-       .type   __acle_se_invalid_10, %function<br>
-       .type   invalid_10, %function<br>
-__acle_se_invalid_10 = 0x10001<br>
-invalid_10 = 0x10005<br>
-       .size   invalid_10, 0<br>
-  .size __acle_se_invalid_10, 0<br>
-<br>
-  .section nonthumb<br>
-  .thumb<br>
-  .align  2<br>
-  .global  invalid_11<br>
-  .global  __acle_se_invalid_11<br>
-  .type  invalid_11, %function<br>
-  .type  __acle_se_invalid_11, %function<br>
-invalid_11:<br>
-  .size  invalid_11, .-invalid_11<br>
-/// Invalid non-thumb function symbol __acle_se_invalid_11<br>
-__acle_se_invalid_11=0x1000<br>
-<br>
-  .global  invalid_12<br>
-  .global  __acle_se_invalid_12<br>
-  .type  invalid_12, %function<br>
-  .type  __acle_se_invalid_12, %function<br>
-/// Invalid non-thumb function symbol invalid_12<br>
-invalid_12=0x1000<br>
-  .thumb<br>
-__acle_se_invalid_12:<br>
-  .size  __acle_se_invalid_12, .-__acle_se_invalid_12<br>
-<br>
-//--- libv1<br>
-.include "arm-cmse-macros.s"<br>
-<br>
-  .text<br>
-  .thumb<br>
-<br>
-/// Import library version 1 with foo and bar<br>
-  cmse_veneer foo, function, global, function, global<br>
-  cmse_veneer bar, function,   weak, function,   weak<br>
-<br>
-//--- libv2<br>
-.include "arm-cmse-macros.s"<br>
-<br>
-  .text<br>
-  .thumb<br>
-<br>
-/// Import library version 2 with bar missing.<br>
-  cmse_veneer bar, function,   weak, function,   weak<br>
<br>
diff  --git a/lld/test/ELF/arm-cmse-implib.s b/lld/test/ELF/arm-cmse-implib.s<br>
deleted file mode 100644<br>
index 3f643a132f6cd..0000000000000<br>
--- a/lld/test/ELF/arm-cmse-implib.s<br>
+++ /dev/null<br>
@@ -1,114 +0,0 @@<br>
-// REQUIRES: arm<br>
-/// Test that addresses of secure gateways in an old import library are maintained in new import libraries.<br>
-<br>
-// RUN: rm -rf %t && split-file %s %t && cd %t<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.base app -o app.o<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.base implib-v1 -I %S/Inputs -o 1.o<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.base implib-v2 -I %S/Inputs -o 2.o<br>
-<br>
-// RUN: ld.lld -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o 1 app.o --out-implib=1.lib --cmse-implib 1.o<br>
-// RUN: llvm-readelf -s 1 1.lib | FileCheck %s --check-prefixes=CHECK1<br>
-<br>
-// RUN: ld.lld -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 -o 2 app.o --out-implib=2.lib --in-implib=1.lib --cmse-implib 2.o<br>
-// RUN: llvm-readelf -s 2 2.lib | FileCheck %s --check-prefixes=CHECK2<br>
-<br>
-//--- app<br>
-<br>
-       .align  2<br>
-       .global secure_entry<br>
-       .type   secure_entry, %function<br>
-secure_entry:<br>
-       nop<br>
-       .size   secure_entry, .-secure_entry<br>
-<br>
-//--- implib-v1<br>
-<br>
-    .include "arm-cmse-macros.s"<br>
-<br>
-    .syntax unified<br>
-    .text<br>
-<br>
-  cmse_veneer foo, function, global, function, global<br>
-  cmse_veneer bar, function, weak, function, global<br>
-  cmse_no_veneer no_veneer1, function, weak, function, global<br>
-  cmse_no_veneer no_veneer2, function, weak, function, weak<br>
-<br>
-//--- implib-v2<br>
-<br>
-    .include "arm-cmse-macros.s"<br>
-<br>
-    .syntax unified<br>
-    .text<br>
-<br>
-  cmse_veneer baz, function, weak, function, global<br>
-  cmse_veneer foo, function, global, function, global<br>
-  cmse_veneer bar, function, weak, function, global<br>
-  cmse_veneer qux, function, global, function, global<br>
-  cmse_no_veneer no_veneer1, function, weak, function, global<br>
-  cmse_no_veneer no_veneer2, function, weak, function, weak<br>
-<br>
-/// Executable 1<br>
-// CHECK1:      File:<br>
-// CHECK1:      Symbol table '.symtab' contains 13 entries:<br>
-// CHECK1-NEXT:    Num:    Value  Size Type    Bind   Vis       Ndx Name<br>
-// CHECK1-NEXT:      0: 00000000     0 NOTYPE  LOCAL  DEFAULT   UND<br>
-// CHECK1-NEXT:      1: 00020000     0 NOTYPE  LOCAL  DEFAULT     2 $t<br>
-// CHECK1-NEXT:      2: 00008000     0 NOTYPE  LOCAL  DEFAULT     1 $t.0<br>
-// CHECK1-NEXT:      3: 00008004     0 NOTYPE  LOCAL  DEFAULT     1 $t.0<br>
-// CHECK1-NEXT:      4: 00008001     2 FUNC    GLOBAL DEFAULT     1 secure_entry<br>
-// CHECK1-NEXT:      5: 00020009     8 FUNC    GLOBAL DEFAULT     2 foo<br>
-// CHECK1-NEXT:      6: 00008005     2 FUNC    GLOBAL DEFAULT     1 __acle_se_foo<br>
-// CHECK1-NEXT:      7: 00020001     8 FUNC    WEAK   DEFAULT     2 bar<br>
-// CHECK1-NEXT:      8: 00008009     2 FUNC    GLOBAL DEFAULT     1 __acle_se_bar<br>
-// CHECK1-NEXT:      9: 0000800d     8 FUNC    WEAK   DEFAULT     1 no_veneer1<br>
-// CHECK1-NEXT:     10: 00008013     2 FUNC    GLOBAL DEFAULT     1 __acle_se_no_veneer1<br>
-// CHECK1-NEXT:     11: 00008015     8 FUNC    WEAK   DEFAULT     1 no_veneer2<br>
-// CHECK1-NEXT:     12: 0000801b     2 FUNC    WEAK   DEFAULT     1 __acle_se_no_veneer2<br>
-<br>
-<br>
-/// Import library 1<br>
-// CHECK1:      File:<br>
-// CHECK1:      Symbol table '.symtab' contains 5 entries:<br>
-// CHECK1-NEXT:    Num:    Value  Size Type    Bind   Vis       Ndx Name<br>
-// CHECK1-NEXT:      0: 00000000     0 NOTYPE  LOCAL  DEFAULT   UND<br>
-// CHECK1-NEXT:      1: 0000800d     8 FUNC    WEAK   DEFAULT   ABS no_veneer1<br>
-// CHECK1-NEXT:      2: 00008015     8 FUNC    WEAK   DEFAULT   ABS no_veneer2<br>
-// CHECK1-NEXT:      3: 00020001     8 FUNC    WEAK   DEFAULT   ABS bar<br>
-// CHECK1-NEXT:      4: 00020009     8 FUNC    GLOBAL DEFAULT   ABS foo<br>
-<br>
-/// Executable 2<br>
-// CHECK2:      File:<br>
-// CHECK2:      Symbol table '.symtab' contains 17 entries:<br>
-// CHECK2-NEXT:    Num:    Value  Size Type    Bind   Vis       Ndx Name<br>
-// CHECK2-NEXT:      0: 00000000     0 NOTYPE  LOCAL  DEFAULT   UND<br>
-// CHECK2-NEXT:      1: 00020000     0 NOTYPE  LOCAL  DEFAULT     2 $t<br>
-// CHECK2-NEXT:      2: 00008000     0 NOTYPE  LOCAL  DEFAULT     1 $t.0<br>
-// CHECK2-NEXT:      3: 00008004     0 NOTYPE  LOCAL  DEFAULT     1 $t.0<br>
-// CHECK2-NEXT:      4: 00008001     2 FUNC    GLOBAL DEFAULT     1 secure_entry<br>
-// CHECK2-NEXT:      5: 00020019     8 FUNC    WEAK   DEFAULT     2 baz<br>
-// CHECK2-NEXT:      6: 00008005     2 FUNC    GLOBAL DEFAULT     1 __acle_se_baz<br>
-// CHECK2-NEXT:      7: 00020009     8 FUNC    GLOBAL DEFAULT     2 foo<br>
-// CHECK2-NEXT:      8: 00008009     2 FUNC    GLOBAL DEFAULT     1 __acle_se_foo<br>
-// CHECK2-NEXT:      9: 00020001     8 FUNC    WEAK   DEFAULT     2 bar<br>
-// CHECK2-NEXT:     10: 0000800d     2 FUNC    GLOBAL DEFAULT     1 __acle_se_bar<br>
-// CHECK2-NEXT:     11: 00020011     8 FUNC    GLOBAL DEFAULT     2 qux<br>
-// CHECK2-NEXT:     12: 00008011     2 FUNC    GLOBAL DEFAULT     1 __acle_se_qux<br>
-// CHECK2-NEXT:     13: 00008015     8 FUNC    WEAK   DEFAULT     1 no_veneer1<br>
-// CHECK2-NEXT:     14: 0000801b     2 FUNC    GLOBAL DEFAULT     1 __acle_se_no_veneer1<br>
-// CHECK2-NEXT:     15: 0000801d     8 FUNC    WEAK   DEFAULT     1 no_veneer2<br>
-// CHECK2-NEXT:     16: 00008023     2 FUNC    WEAK   DEFAULT     1 __acle_se_no_veneer2<br>
-<br>
-<br>
-/// Note that foo retains its address from Import library 1 (0x000020009)<br>
-/// New entry functions, baz and qux, use addresses not used by Import library 1.<br>
-/// Import library 2<br>
-// CHECK2:      File:<br>
-// CHECK2:      Symbol table '.symtab' contains 7 entries:<br>
-// CHECK2-NEXT:    Num:    Value  Size Type    Bind   Vis       Ndx Name<br>
-// CHECK2-NEXT:      0: 00000000     0 NOTYPE  LOCAL  DEFAULT   UND<br>
-// CHECK2-NEXT:      1: 00008015     8 FUNC    WEAK   DEFAULT   ABS no_veneer1<br>
-// CHECK2-NEXT:      2: 0000801d     8 FUNC    WEAK   DEFAULT   ABS no_veneer2<br>
-// CHECK2-NEXT:      3: 00020001     8 FUNC    WEAK   DEFAULT   ABS bar<br>
-// CHECK2-NEXT:      4: 00020009     8 FUNC    GLOBAL DEFAULT   ABS foo<br>
-// CHECK2-NEXT:      5: 00020011     8 FUNC    GLOBAL DEFAULT   ABS qux<br>
-// CHECK2-NEXT:      6: 00020019     8 FUNC    WEAK   DEFAULT   ABS baz<br>
<br>
diff  --git a/lld/test/ELF/arm-cmse-keep-sections.s b/lld/test/ELF/arm-cmse-keep-sections.s<br>
deleted file mode 100644<br>
index 5157da77cd5e8..0000000000000<br>
--- a/lld/test/ELF/arm-cmse-keep-sections.s<br>
+++ /dev/null<br>
@@ -1,55 +0,0 @@<br>
-// REQUIRES: arm<br>
-/// Create a secure app and import library using CMSE.<br>
-/// Create a non-secure app that refers symbols in the import library.<br>
-<br>
-// RUN: rm -rf %t && split-file %s %t && cd %t<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.main cmse-implib.s -o implib.o -I%S/Inputs/<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.main cmse-secure-app.s -o secureapp.o<br>
-/// Create the secure app and import library.<br>
-// RUN: ld.lld -e secure_entry --section-start .gnu.sgstubs=0x1000000 --section-start SECURE1=0x10 --section-start SECURE2=0x2000000 --cmse-implib implib.o secureapp.o --out-implib=implib.lib -o secureapp --gc-sections<br>
-// RUN: llvm-readelf -s implib.lib | FileCheck %s<br>
-// RUN: llvm-objdump -d --no-show-raw-insn secureapp | FileCheck %s --check-prefix=DISS<br>
-<br>
-<br>
-// DISS-LABEL: <__acle_se_entry1>:<br>
-// DISS-NEXT:  10: nop<br>
-<br>
-// DISS-LABEL: <entry2>:<br>
-// DISS-NEXT: 1000000: sg<br>
-// DISS-LABEL:         b.w {{.*}} <__acle_se_entry2><br>
-<br>
-// DISS-LABEL: <entry1>:<br>
-// DISS-NEXT: 1000008: sg<br>
-// DISS-LABEL:         b.w {{.*}} <__acle_se_entry1><br>
-<br>
-// DISS-LABEL: <__acle_se_entry2>:<br>
-// DISS-NEXT:  2000000: nop<br>
-<br>
-// CHECK:    Symbol table '.symtab' contains {{.*}} entries:<br>
-// CHECK-NEXT:  Num:  Value  Size Type  Bind   Vis     Ndx Name<br>
-// CHECK-NEXT:    0: 00000000   0 NOTYPE  LOCAL  DEFAULT   UND<br>
-// CHECK-NEXT:    1: 01000001   8 FUNC  GLOBAL DEFAULT   ABS entry2<br>
-// CHECK-NEXT:    2: 01000009   8 FUNC  GLOBAL DEFAULT   ABS entry1<br>
-<br>
-//--- cmse-implib.s<br>
-  .include "arm-cmse-macros.s"<br>
-<br>
-  .syntax unified<br>
-  .section SECURE1, "ax"<br>
-<br>
-  cmse_veneer entry1, function, global, function, global<br>
-<br>
-  .syntax unified<br>
-  .section SECURE2, "ax"<br>
-<br>
-  cmse_veneer entry2, function, global, function, global<br>
-<br>
-//--- cmse-secure-app.s<br>
-  .text<br>
-  .align  2<br>
-  // Main entry point.<br>
-  .global secure_entry<br>
-  .thumb_func<br>
-secure_entry:<br>
-  bx lr<br>
-  .size  secure_entry, .-secure_entry<br>
<br>
diff  --git a/lld/test/ELF/arm-cmse-noveneers.s b/lld/test/ELF/arm-cmse-noveneers.s<br>
deleted file mode 100644<br>
index 19e7a45e356b9..0000000000000<br>
--- a/lld/test/ELF/arm-cmse-noveneers.s<br>
+++ /dev/null<br>
@@ -1,30 +0,0 @@<br>
-// REQUIRES: arm<br>
-/// Test that addresses of existing secure gateway veneers are output in the CMSE import library.<br>
-/// Test that .gnu.sgstubs is size 0 when no linker synthesized secure gateway veneers are created.<br>
-<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.main %s -I %S/Inputs -o %t.o<br>
-// RUN: ld.lld --cmse-implib -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 %t.o -o %t --out-implib=%t.lib<br>
-// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s<br>
-// RUN: llvm-readelf -S %t | FileCheck %s --check-prefixes=SGSTUBSSIZE<br>
-// RUN: llvm-readelf -s %t.lib | FileCheck %s --check-prefixes=IMPLIBSYMS<br>
-<br>
-// CHECK: Disassembly of section .text:<br>
-<br>
-// CHECK-LABEL: <existing_veneer>:<br>
-// CHECK-NEXT:     8000: sg<br>
-// CHECK-NEXT:     8004: nop<br>
-<br>
-// CHECK-LABEL: <__acle_se_existing_veneer>:<br>
-// CHECK-NEXT:     8006: nop<br>
-<br>
- .include "arm-cmse-macros.s"<br>
-<br>
-  cmse_no_veneer existing_veneer, function, global, function, global<br>
-<br>
-///                      Name          Type         Address    Off   Size ES Flg Lk Inf Al<br>
-// SGSTUBSSIZE: .gnu.sgstubs      PROGBITS        00020000 020000 000000 08  AX  0   0 32<br>
-<br>
-// IMPLIBSYMS:      Symbol table '.symtab' contains 2 entries:<br>
-// IMPLIBSYMS-NEXT:    Num:    Value  Size Type    Bind   Vis       Ndx Name<br>
-// IMPLIBSYMS-NEXT:      0: 00000000     0 NOTYPE  LOCAL  DEFAULT   UND<br>
-// IMPLIBSYMS-NEXT:      1: 00008001     8 FUNC    GLOBAL DEFAULT   ABS existing_veneer<br>
<br>
diff  --git a/lld/test/ELF/arm-cmse-secure.s b/lld/test/ELF/arm-cmse-secure.s<br>
deleted file mode 100644<br>
index d6fb661c46493..0000000000000<br>
--- a/lld/test/ELF/arm-cmse-secure.s<br>
+++ /dev/null<br>
@@ -1,68 +0,0 @@<br>
-// REQUIRES: arm<br>
-/// Create a secure app and import library using CMSE.<br>
-/// Create a non-secure app that refers symbols in the import library.<br>
-<br>
-// RUN: rm -rf %t && split-file %s %t && cd %t<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.main cmse-implib.s -o implib.o -I%S/Inputs/<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.main cmse-secure-app.s -o secureapp.o<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.main cmse-non-secure-app.s -o nonsecureapp.o<br>
-/// Create the secure app and import library.<br>
-// RUN: ld.lld -e secure_entry --section-start .gnu.sgstubs=0x20000 --cmse-implib implib.o secureapp.o --out-implib=implib.lib -o secureapp<br>
-/// Link the non-secure app against the import library.<br>
-// RUN: ld.lld -e nonsecure_entry -Ttext=0x8000 implib.lib nonsecureapp.o -o nonsecureapp<br>
-// RUN: llvm-readelf -s implib.lib | FileCheck %s<br>
-// RUN: llvm-objdump -d --no-show-raw-insn secureapp | FileCheck %s --check-prefixes=SECUREDISS<br>
-// RUN: llvm-objdump -d --no-show-raw-insn nonsecureapp | FileCheck %s --check-prefixes=NONSECUREDISS<br>
-<br>
-// SECUREDISS-LABEL: <entry>:<br>
-// SECUREDISS-NEXT:    20000: sg<br>
-// SECUREDISS-NEXT:           b.w {{.*}} <__acle_se_entry><br>
-<br>
-// SECUREDISS-LABEL: <__acle_se_entry>:<br>
-// SECUREDISS-NEXT:    20008: nop<br>
-<br>
-// SECUREDISS-LABEL: <secure_entry>:<br>
-// SECUREDISS-NEXT:    2000c: bl {{.*}} <__acle_se_entry><br>
-// SECUREDISS-NEXT:           bx lr<br>
-<br>
-// NONSECUREDISS-LABEL: <nonsecure_entry>:<br>
-// NONSECUREDISS-NEXT:  8000: push {r0, lr}<br>
-// NONSECUREDISS-NEXT:  bl 0x20000<br>
-// NONSECUREDISS-NEXT:  pop.w {r0, lr}<br>
-// NONSECUREDISS-NEXT:  bx lr<br>
-<br>
-// CHECK:      Symbol table '.symtab' contains 2 entries:<br>
-// CHECK-NEXT:    Num:    Value  Size Type    Bind   Vis       Ndx Name<br>
-// CHECK-NEXT:      0: 00000000     0 NOTYPE  LOCAL  DEFAULT   UND<br>
-// CHECK-NEXT:      1: 00020001     8 FUNC    GLOBAL DEFAULT   ABS entry<br>
-<br>
-//--- cmse-implib.s<br>
-  .include "arm-cmse-macros.s"<br>
-<br>
-  .syntax unified<br>
-  .text<br>
-<br>
-  cmse_veneer entry, function, global, function, global<br>
-<br>
-//--- cmse-secure-app.s<br>
-  .align  2<br>
-    // Main entry point.<br>
-    .global secure_entry<br>
-    .thumb_func<br>
-secure_entry:<br>
-    bl entry<br>
-    bx lr<br>
-  .size  secure_entry, .-secure_entry<br>
-<br>
-//--- cmse-non-secure-app.s<br>
-  .align  2<br>
-  .global nonsecure_entry<br>
-  .thumb<br>
-  .thumb_func<br>
-  .type  nonsecure_entry, %function<br>
-nonsecure_entry:<br>
-  push {r0,lr}<br>
-  bl entry<br>
-  pop {r0,lr}<br>
-  bx lr<br>
-  .size  nonsecure_entry, .-nonsecure_entry<br>
<br>
diff  --git a/lld/test/ELF/arm-cmse-veneers.s b/lld/test/ELF/arm-cmse-veneers.s<br>
deleted file mode 100644<br>
index e9b4e6d28a956..0000000000000<br>
--- a/lld/test/ELF/arm-cmse-veneers.s<br>
+++ /dev/null<br>
@@ -1,42 +0,0 @@<br>
-// REQUIRES: arm<br>
-/// Test that symbol visibilities of <sym, __acle_se_sym> pairs in the objects<br>
-/// are preserved in the executable.<br>
-<br>
-// RUN: llvm-mc -arm-add-build-attributes -filetype=obj --triple=thumbv8m.main %s -I %S/Inputs -o %t.o<br>
-// RUN: ld.lld --cmse-implib -Ttext=0x8000 --section-start .gnu.sgstubs=0x20000 %t.o -o %t<br>
-// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s<br>
-// RUN: llvm-readelf -s %t | FileCheck %s --check-prefixes=SYM<br>
-<br>
-// CHECK: Disassembly of section .gnu.sgstubs:<br>
-<br>
-// CHECK-LABEL: <weak_qux>:<br>
-// CHECK-NEXT:    20000: sg<br>
-// CHECK-NEXT:           b.w {{.*}} <__acle_se_weak_qux><br>
-// CHECK-EMPTY:<br>
-// CHECK-LABEL: <global_baz>:<br>
-// CHECK-NEXT:    20008: sg<br>
-// CHECK-NEXT:           b.w {{.*}} <__acle_se_global_baz><br>
-// CHECK-EMPTY:<br>
-// CHECK-LABEL: <weak_bar>:<br>
-// CHECK-NEXT:    20010: sg<br>
-// CHECK-NEXT:           b.w {{.*}} <__acle_se_weak_bar><br>
-// CHECK-EMPTY:<br>
-// CHECK-LABEL: <global_foo>:<br>
-// CHECK-NEXT:    20018: sg<br>
-// CHECK-NEXT:           b.w {{.*}} <__acle_se_global_foo><br>
-<br>
-// SYM: 00020019 {{.*}} GLOBAL {{.*}}           global_foo<br>
-// SYM: 00008001 {{.*}} GLOBAL {{.*}} __acle_se_global_foo<br>
-// SYM: 00020011 {{.*}} WEAK   {{.*}}           weak_bar<br>
-// SYM: 00008005 {{.*}} WEAK   {{.*}} __acle_se_weak_bar<br>
-// SYM: 00020009 {{.*}} GLOBAL {{.*}}           global_baz<br>
-// SYM: 00008009 {{.*}} WEAK   {{.*}} __acle_se_global_baz<br>
-// SYM: 00020001 {{.*}} WEAK   {{.*}}           weak_qux<br>
-// SYM: 0000800d {{.*}} GLOBAL {{.*}} __acle_se_weak_qux<br>
-<br>
-  .include "arm-cmse-macros.s"<br>
-<br>
-  cmse_veneer global_foo, function, global, function, global<br>
-  cmse_veneer weak_bar, function, weak, function, weak<br>
-  cmse_veneer global_baz, function, global, function, weak<br>
-  cmse_veneer weak_qux, function, weak, function, global<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>