This fixes PR49821, and avoids "ld.lld: error: test.o:(.rodata.str1.1):
offset is outside the section" errors when linking certain MIPS objects.
A root of the problem is in the R_MIPS_LO16 relocation handling. Both
R_MIPS_HI16 and R_MIPS_LO16 are considered as absolute relocations (theMIPS objects with
type is R_ABS).negative R_MIPS_LO16 implicit addends.
ld.lld handles R_MIPS_HI16/R_MIPS_LO16 separately, not as a whole, When we calculate R_MIPS_HI16's addend we find a pairedso it
R_MIPS_LO16, generate combined addend and return correct symbol valuedoesn't know that an R_MIPS_HI16 with implicit addend 1 and an
from the InputSectionBase::getRelocTargetVA.R_MIPS_LO16 with implicit addend -32768 represents 32768, For R_MIPS_LO16 we do notwhich is in
do that and use its addend as isrange of a MergeInputSection. Probably we shWe could introduce a new RelExpr member
expression type(like R_RISCV_PC_INDIRECT for these relocations (likeR_RISCV_PCREL_HI20 / R_RISCV_PC_INDIRECT forREL_LO12)
R_RISCV_PCREL_HI20 / R_RISCV_PCREL_LO12) and calculate a correct symbolbut the complexity is unnecessary given that GNU as keeps the original
valuesymbol for both relocations at the InputSectionBase::getRelocTargetVAthis case as well.