[PATCH] D34689: [LLD][ELF] Pre-create ThunkSections at Target specific intervals

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 14 12:04:58 PDT 2017


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

> +  forEachExecInputSectionRange(
> +      OutputSections, [&](OutputSection *OS, std::vector<InputSection *> *ISR) {
> +        for (InputSection *IS : *ISR) {
> +          if (ISR != PrevISR) {
> +            NeedTrailingTS = true;
> +            Off = 0;
> +            Limit = IS->OutSecOff +
> +                    (Target->ThunkSectionSpacing - Target->ThunkSectionSize);
> +            PrevIS = nullptr;
> +            PrevISR = ISR;
> +          }
> +          Off = IS->OutSecOff + IS->getSize();
> +          if (Off >= Limit) {
> +            uint32_t ThunkOff = (PrevIS == nullptr)
> +                                    ? IS->OutSecOff
> +                                    : PrevIS->OutSecOff + PrevIS->getSize();
> +            addThunkSection(OS, ISR, ThunkOff);
> +            NeedTrailingTS = false;
> +            Limit = ThunkOff + Target->ThunkSectionSpacing;
> +          }

Should this add (Target->ThunkSectionSpacing - Target->ThunkSectionSize)
instead?

A branch immediately after the previous thunk section will now be more
than ThunkSectionSize away from the end of the following thunk section.

Cheers,
Rafael


More information about the llvm-commits mailing list