[PATCH] D33496: [LLD][ELF] Move creation of .ARM.exidx sentinel before LinkerScript creation

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu May 25 15:28:00 PDT 2017


> -  // So far we have added sections from input object files.
> -  // This function adds linker-created Out::* sections.
>    addPredefinedSections();
>    removeUnusedSyntheticSections(OutputSections);

Any reason for removing the comment?

> @@ -1264,8 +1262,17 @@
>    // ARM ABI requires .ARM.exidx to be terminated by some piece of data.
>    // We have the terminater synthetic section class. Add that at the end.
>    auto *OS = dyn_cast_or_null<OutputSection>(findSection(".ARM.exidx"));
> -  if (OS && !OS->Sections.empty() && !Config->Relocatable)
> -    OS->addSection(make<ARMExidxSentinelSection>());
> +  if (!OS || OS->Sections.empty() || Config->Relocatable)
> +    return;
> +
> +  auto *Sentinel = make<ARMExidxSentinelSection>();
> +  OS->addSection(Sentinel);
> +  // If there are linker script commands existing at this point then add the
> +  // sentinel to these too.
> +  std::vector<std::vector<InputSection *> *> Ranges =
> +      Script->inputSectionRanges(OS->Name);
> +  if (!Ranges.empty())
> +    Ranges.back()->push_back(Sentinel);

Can you use Script->getCmd(OS) to get the OutputSectionCommand instead?
With that it should be easy to create a dummy InputSectionDescription
and add it.

This is an improvement, and using getCmd should hopefully be all that is
left.

Cheers,
Rafael


More information about the llvm-commits mailing list