ELF: Simplify Target::isSizeReloc and add comments.
All non-trivial relocation decisions need explanations like this
to help readers understand not only how relocations are handled but
why they are handled these ways. This is a start.
llvm-svn: 257119
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index b490793..3e949ff 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -219,8 +219,13 @@
} else if (!Target->needsCopyRel(Type, *Body) &&
isa<SharedSymbol<ELFT>>(*Body)) {
continue;
- } else if (Target->isTlsDynReloc(Type, *Body) ||
- Target->isSizeDynReloc(Type, *Body)) {
+ } else if (Target->isTlsDynReloc(Type, *Body)) {
+ continue;
+ } else if (Target->isSizeReloc(Type) && canBePreempted(Body, false)) {
+ // A SIZE relocation is supposed to set a symbol size, but if a symbol
+ // can be preempted, the size at runtime may be different than link time.
+ // If that's the case, we leave the field alone rather than filling it
+ // with a possibly incorrect value.
continue;
} else if (Config->EMachine == EM_MIPS) {
if (Type == R_MIPS_HI16 && Body == Config->MipsGpDisp)