[lld] r298792 - Add comments and return early.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 25 23:16:17 PDT 2017


On Sat, Mar 25, 2017 at 10:21 PM, Sean Silva via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> what does "non-interruptable" mean in this context? in the same segment?
>

Unless I'm reading the context incorrectly, it's a synonym for not
preemptible at runtime.
In case my guess is right, I really dislike the word `interruptible`
because is such an overloaded word in systems.
I'd rather use `interposable` or `preemptible` (to the best of my
knowledge they're all synonyms in ELF, but please double
check/confirm).

> On Mar 25, 2017 9:32 PM, "Rui Ueyama via llvm-commits"
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: ruiu
>> Date: Sat Mar 25 22:20:30 2017
>> New Revision: 298792
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=298792&view=rev
>> Log:
>> Add comments and return early.
>>
>> Modified:
>>     lld/trunk/ELF/Relocations.cpp
>>
>> Modified: lld/trunk/ELF/Relocations.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=298792&r1=298791&r2=298792&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/ELF/Relocations.cpp (original)
>> +++ lld/trunk/ELF/Relocations.cpp Sat Mar 25 22:20:30 2017
>> @@ -312,6 +312,15 @@ static bool isRelExpr(RelExpr Expr) {
>>                          R_PAGE_PC, R_RELAX_GOT_PC>(Expr);
>>  }
>>
>> +// Returns true if a given relocation can be computed at link-time.
>> +//
>> +// For instance, we know the offset from a relocation to its target at
>> +// link-time if the relocation is PC-relative and refers a
>> +// (non-interruptible) function in the same executable. This function
>> +// will return true for such relocation.
>> +//
>> +// If this function returns false, that means we need to emit a
>> +// dynamic relocation so that the relocation will be fixed at load-time.
>>  template <class ELFT>
>>  static bool
>>  isStaticLinkTimeConstant(RelExpr E, uint32_t Type, const SymbolBody
>> &Body,
>> @@ -331,16 +340,19 @@ isStaticLinkTimeConstant(RelExpr E, uint
>>
>>    if (isPreemptible(Body, Type))
>>      return false;
>> -
>>    if (!Config->Pic)
>>      return true;
>>
>> +  // For the target and the relocation, we want to know if they are
>> +  // absolute or relative.
>>    bool AbsVal = isAbsoluteValue<ELFT>(Body);
>>    bool RelE = isRelExpr(E);
>>    if (AbsVal && !RelE)
>>      return true;
>>    if (!AbsVal && RelE)
>>      return true;
>> +  if (!AbsVal && !RelE)
>> +    return Target->usesOnlyLowPageBits(Type);
>>
>>    // Relative relocation to an absolute value. This is normally
>> unrepresentable,
>>    // but if the relocation refers to a weak undefined symbol, we allow it
>> to
>> @@ -350,16 +362,14 @@ isStaticLinkTimeConstant(RelExpr E, uint
>>    // Another special case is MIPS _gp_disp symbol which represents offset
>>    // between start of a function and '_gp' value and defined as absolute
>> just
>>    // to simplify the code.
>> -  if (AbsVal && RelE) {
>> -    if (Body.isUndefined() && !Body.isLocal() && Body.symbol()->isWeak())
>> -      return true;
>> -    error(S.getLocation<ELFT>(RelOff) + ": relocation " + toString(Type)
>> +
>> -          " cannot refer to absolute symbol '" + toString(Body) +
>> -          "' defined in " + toString(Body.File));
>> +  assert(AbsVal && RelE);
>> +  if (Body.isUndefined() && !Body.isLocal() && Body.symbol()->isWeak())
>>      return true;
>> -  }
>>
>> -  return Target->usesOnlyLowPageBits(Type);
>> +  error(S.getLocation<ELFT>(RelOff) + ": relocation " + toString(Type) +
>> +        " cannot refer to absolute symbol '" + toString(Body) +
>> +        "' defined in " + toString(Body.File));
>> +  return true;
>>  }
>>
>>  static RelExpr toPlt(RelExpr Expr) {
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>

-- 
Davide

"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare


More information about the llvm-commits mailing list