Skip to content

Commit 71d7e69

Browse files
committed
[ELF] Implement getImplicitAddend and enable checkDynamicRelocsDefault for Hexagon
1 parent 693aa68 commit 71d7e69

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

lld/ELF/Arch/Hexagon.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Hexagon final : public TargetInfo {
2929
RelExpr getRelExpr(RelType type, const Symbol &s,
3030
const uint8_t *loc) const override;
3131
RelType getDynRel(RelType type) const override;
32+
int64_t getImplicitAddend(const uint8_t *buf, RelType type) const override;
3233
void relocate(uint8_t *loc, const Relocation &rel,
3334
uint64_t val) const override;
3435
void writePltHeader(uint8_t *buf) const override;
@@ -386,6 +387,25 @@ RelType Hexagon::getDynRel(RelType type) const {
386387
return R_HEX_NONE;
387388
}
388389

390+
int64_t Hexagon::getImplicitAddend(const uint8_t *buf, RelType type) const {
391+
switch (type) {
392+
case R_HEX_NONE:
393+
case R_HEX_GLOB_DAT:
394+
case R_HEX_JMP_SLOT:
395+
return 0;
396+
case R_HEX_32:
397+
case R_HEX_RELATIVE:
398+
case R_HEX_DTPMOD_32:
399+
case R_HEX_DTPREL_32:
400+
case R_HEX_TPREL_32:
401+
return SignExtend64<32>(read32(buf));
402+
default:
403+
internalLinkerError(getErrorLocation(buf),
404+
"cannot read addend for relocation " + toString(type));
405+
return 0;
406+
}
407+
}
408+
389409
TargetInfo *elf::getHexagonTargetInfo() {
390410
static Hexagon target;
391411
return &target;

lld/ELF/Driver.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,11 +1709,10 @@ static void setConfigs(opt::InputArgList &args) {
17091709
OPT_no_apply_dynamic_relocs, false) ||
17101710
!config->isRela;
17111711
// Validation of dynamic relocation addends is on by default for assertions
1712-
// builds (for supported targets) and disabled otherwise. Ideally we would
1713-
// enable the debug checks for all targets, but currently not all targets
1714-
// have support for reading Elf_Rel addends, so we only enable for a subset.
1712+
// builds and disabled otherwise. This check is enabled when writeAddends is
1713+
// true.
17151714
#ifndef NDEBUG
1716-
bool checkDynamicRelocsDefault = m != EM_HEXAGON;
1715+
bool checkDynamicRelocsDefault = true;
17171716
#else
17181717
bool checkDynamicRelocsDefault = false;
17191718
#endif

0 commit comments

Comments
 (0)