[PATCH] D28956: [LLD][ELF] Add support for local symbols in Synthetic Sections

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 15:59:33 PST 2017


Peter Smith via Phabricator <reviews at reviews.llvm.org> writes:

> +void ARMTargetInfo::addPltHeaderSymbols(InputSectionData* ISD) const {
> +  auto* IS = dyn_cast<InputSection<ELF32LE>>(ISD);

Can this be a cast<>?

> +  addSyntheticLocal("$a", STT_NOTYPE, 0, 0, IS);
> +  addSyntheticLocal("$d", STT_NOTYPE, 16, 0, IS);
> +}
> +
>  void ARMTargetInfo::writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
>                               uint64_t PltEntryAddr, int32_t Index,
>                               unsigned RelOff) const {
> @@ -1748,6 +1756,13 @@
>    write32le(Buf + 12, GotEntryAddr - L1 - 8);
>  }
>  
> +void ARMTargetInfo::addPltSymbols(InputSectionData* ISD, uint64_t Off) const
> +{
> +  auto* IS = dyn_cast<InputSection<ELF32LE>>(ISD);

and this?

> +  addSyntheticLocal("$a", STT_NOTYPE, Off, 0, IS);
> +  addSyntheticLocal("$d", STT_NOTYPE, Off + 12, 0, IS);
> +}
> +
>  RelExpr ARMTargetInfo::getThunkExpr(RelExpr Expr, uint32_t RelocType,
>                                      const InputFile *File,
>                                      const SymbolBody &S) const {

> +  return S;
> +}
> +
>  static size_t getHashSize() {
>    switch (Config->BuildId) {
>    case BuildIdKind::Fast:
> @@ -1441,6 +1453,15 @@
>    return Target->PltHeaderSize + Entries.size() * Target->PltEntrySize;
>  }
>  
> +template <class ELFT> void PltSection<ELFT>::addSymbols() {
> +  Target->addPltHeaderSymbols(this);
> +  size_t Off = Target->PltHeaderSize;
> +  for (size_t I = 0; I < Entries.size(); ++I) {
> +    Target->addPltSymbols(this, Off);
> +    Off += Target->PltEntrySize;
> +  }
> +}
> +
>  template <class ELFT>
>  IpltSection<ELFT>::IpltSection()
>      : SyntheticSection<ELFT>(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 16,
> @@ -1471,6 +1492,14 @@
>    return Entries.size() * Target->PltEntrySize;
>  }
>  
> +template <class ELFT> void IpltSection<ELFT>::addSymbols() {
> +  size_t Off = 0;
> +  for (size_t I = 0; I < Entries.size(); ++I) {
> +    Target->addPltSymbols(this, Off);
> +    Off += Target->PltEntrySize;
> +  }
> +}

Would it be possible to add a common base class to PltSection and
Ipltsection and share this code?

These can be done after commit, LGTM.

Cheers,
Rafael


More information about the llvm-commits mailing list