@@ -306,7 +306,9 @@ static bool isRelExpr(RelExpr Expr) {
306
306
307
307
template <class ELFT >
308
308
static bool isStaticLinkTimeConstant (RelExpr E, uint32_t Type,
309
- const SymbolBody &Body) {
309
+ const SymbolBody &Body,
310
+ InputSectionBase<ELFT> &S,
311
+ typename ELFT::uint RelOff) {
310
312
// These expressions always compute a constant
311
313
if (E == R_SIZE || E == R_GOT_FROM_END || E == R_GOT_OFF ||
312
314
E == R_MIPS_GOT_LOCAL_PAGE || E == R_MIPS_GOT_OFF ||
@@ -342,8 +344,9 @@ static bool isStaticLinkTimeConstant(RelExpr E, uint32_t Type,
342
344
if (AbsVal && RelE) {
343
345
if (Body.isUndefined () && !Body.isLocal () && Body.symbol ()->isWeak ())
344
346
return true ;
345
- error (" relocation " + getRelName (Type) +
346
- " cannot refer to absolute symbol " + Body.getName ());
347
+ error (getLocation (S, RelOff) + " : relocation " + getRelName (Type) +
348
+ " cannot refer to absolute symbol '" + Body.getName () +
349
+ " ' defined in " + getFilename (Body.File ));
347
350
return true ;
348
351
}
349
352
@@ -421,7 +424,8 @@ template <class ELFT> static void addCopyRelSymbol(SharedSymbol<ELFT> *SS) {
421
424
template <class ELFT >
422
425
static RelExpr adjustExpr (const elf::ObjectFile<ELFT> &File, SymbolBody &Body,
423
426
bool IsWrite, RelExpr Expr, uint32_t Type,
424
- const uint8_t *Data) {
427
+ const uint8_t *Data, InputSectionBase<ELFT> &S,
428
+ typename ELFT::uint RelOff) {
425
429
bool Preemptible = isPreemptible (Body, Type);
426
430
if (Body.isGnuIFunc ()) {
427
431
Expr = toPlt (Expr);
@@ -433,7 +437,7 @@ static RelExpr adjustExpr(const elf::ObjectFile<ELFT> &File, SymbolBody &Body,
433
437
}
434
438
Expr = Target->getThunkExpr (Expr, Type, File, Body);
435
439
436
- if (IsWrite || isStaticLinkTimeConstant<ELFT>(Expr, Type, Body))
440
+ if (IsWrite || isStaticLinkTimeConstant<ELFT>(Expr, Type, Body, S, RelOff ))
437
441
return Expr;
438
442
439
443
// This relocation would require the dynamic linker to write a value to read
@@ -645,7 +649,8 @@ static void scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
645
649
646
650
RelExpr Expr = Target->getRelExpr (Type, Body);
647
651
bool Preemptible = isPreemptible (Body, Type);
648
- Expr = adjustExpr (*File, Body, IsWrite, Expr, Type, Buf + RI.r_offset );
652
+ Expr = adjustExpr (*File, Body, IsWrite, Expr, Type, Buf + RI.r_offset , C,
653
+ RI.r_offset );
649
654
if (HasError)
650
655
continue ;
651
656
@@ -690,7 +695,8 @@ static void scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
690
695
Expr == R_THUNK_PLT_PC || refersToGotEntry (Expr) ||
691
696
!isPreemptible (Body, Type)) {
692
697
// If the relocation points to something in the file, we can process it.
693
- bool Constant = isStaticLinkTimeConstant<ELFT>(Expr, Type, Body);
698
+ bool Constant =
699
+ isStaticLinkTimeConstant<ELFT>(Expr, Type, Body, C, RI.r_offset );
694
700
695
701
// If the output being produced is position independent, the final value
696
702
// is still not known. In that case we still need some help from the
0 commit comments