@@ -451,8 +451,6 @@ class RelocationScanner {
451
451
template <class RelTy > RelType getMipsN32RelType (RelTy *&rel) const ;
452
452
template <class ELFT , class RelTy >
453
453
int64_t computeMipsAddend (const RelTy &rel, RelExpr expr, bool isLocal) const ;
454
- template <class ELFT , class RelTy >
455
- int64_t computeAddend (const RelTy &rel, RelExpr expr, bool isLocal) const ;
456
454
bool isStaticLinkTimeConstant (RelExpr e, RelType type, const Symbol &sym,
457
455
uint64_t relOff) const ;
458
456
void processAux (RelExpr expr, RelType type, uint64_t offset, Symbol &sym,
@@ -497,30 +495,6 @@ int64_t RelocationScanner::computeMipsAddend(const RelTy &rel, RelExpr expr,
497
495
return 0 ;
498
496
}
499
497
500
- // Returns an addend of a given relocation. If it is RELA, an addend
501
- // is in a relocation itself. If it is REL, we need to read it from an
502
- // input section.
503
- template <class ELFT , class RelTy >
504
- int64_t RelocationScanner::computeAddend (const RelTy &rel, RelExpr expr,
505
- bool isLocal) const {
506
- int64_t addend;
507
- RelType type = rel.getType (config->isMips64EL );
508
-
509
- if (RelTy::IsRela) {
510
- addend = getAddend<ELFT>(rel);
511
- } else {
512
- const uint8_t *buf = sec->rawData .data ();
513
- addend = target->getImplicitAddend (buf + rel.r_offset , type);
514
- }
515
-
516
- if (config->emachine == EM_PPC64 && config->isPic && type == R_PPC64_TOC)
517
- addend += getPPC64TocBase ();
518
- if (config->emachine == EM_MIPS)
519
- addend += computeMipsAddend<ELFT>(rel, expr, isLocal);
520
-
521
- return addend;
522
- }
523
-
524
498
// Custom error message if Sym is defined in a discarded section.
525
499
template <class ELFT >
526
500
static std::string maybeReportDiscarded (Undefined &sym) {
@@ -1363,35 +1337,36 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
1363
1337
uint32_t symIndex = rel.getSymbol (config->isMips64EL );
1364
1338
Symbol &sym = sec->getFile <ELFT>()->getSymbol (symIndex);
1365
1339
RelType type;
1366
-
1367
- // Deal with MIPS oddity.
1368
1340
if (config->mipsN32Abi ) {
1369
1341
type = getMipsN32RelType (i);
1370
1342
} else {
1371
1343
type = rel.getType (config->isMips64EL );
1372
1344
++i;
1373
1345
}
1374
-
1375
1346
// Get an offset in an output section this relocation is applied to.
1376
1347
uint64_t offset = getter.get (rel.r_offset );
1377
1348
if (offset == uint64_t (-1 ))
1378
1349
return ;
1379
1350
1380
- // Error if the target symbol is undefined. Symbol index 0 may be used by
1381
- // marker relocations, e.g. R_*_NONE and R_ARM_V4BX. Don't error on them.
1382
- if (sym.isUndefined () && symIndex != 0 &&
1383
- maybeReportUndefined (cast<Undefined>(sym), *sec, offset))
1384
- return ;
1385
-
1386
- const uint8_t *relocatedAddr = sec->rawData .begin () + offset;
1387
- RelExpr expr = target->getRelExpr (type, sym, relocatedAddr);
1351
+ RelExpr expr = target->getRelExpr (type, sym, sec->rawData .data () + offset);
1352
+ int64_t addend =
1353
+ RelTy::IsRela
1354
+ ? getAddend<ELFT>(rel)
1355
+ : target->getImplicitAddend (sec->rawData .data () + rel.r_offset , type);
1356
+ if (LLVM_UNLIKELY (config->emachine == EM_MIPS))
1357
+ addend += computeMipsAddend<ELFT>(rel, expr, sym.isLocal ());
1358
+ else if (config->emachine == EM_PPC64 && config->isPic && type == R_PPC64_TOC)
1359
+ addend += getPPC64TocBase ();
1388
1360
1389
1361
// Ignore R_*_NONE and other marker relocations.
1390
1362
if (expr == R_NONE)
1391
1363
return ;
1392
1364
1393
- // Read an addend.
1394
- int64_t addend = computeAddend<ELFT>(rel, expr, sym.isLocal ());
1365
+ // Error if the target symbol is undefined. Symbol index 0 may be used by
1366
+ // marker relocations, e.g. R_*_NONE and R_ARM_V4BX. Don't error on them.
1367
+ if (sym.isUndefined () && symIndex != 0 &&
1368
+ maybeReportUndefined (cast<Undefined>(sym), *sec, offset))
1369
+ return ;
1395
1370
1396
1371
if (config->emachine == EM_PPC64) {
1397
1372
// We can separate the small code model relocations into 2 categories:
0 commit comments