[PATCH] D45788: Mitigate relocation overflow [part 1 of 2]

Fāng-ruì Sòng via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 14 15:39:17 PDT 2018


On 2018-08-10, PeiHsiangHung via Phabricator wrote:
>NickHung added inline comments.
>Herald added a subscriber: jrtc27.
>
>
>================
>Comment at: test/ELF/linkerscript/addr-zero.test:11
> # CHECK:        Name: foo
>-# CHECK-NEXT:   Value: 0x0
>+# CHECK-NEXT:   Value: 0x38
> # CHECK-NEXT:   Size: 0
>----------------
>This change breaks the value of foo.
>The expected value of foo is 0x0.

// ELF/ScriptParser.cpp:157
static ExprValue sub(ExprValue A, ExprValue B) {
  // The distance between two symbols in sections is absolute.
  if (!A.isAbsolute() && !B.isAbsolute())
    return A.getValue() - B.getValue();
  return {A.Sec, false, A.getSectionOffset() - B.getValue(), A.Loc};
}

(gdb) p A
$1 = {Sec = 0x2742a8, ForceAbsolute = false, Val = 0, Alignment = 1, Loc = "addr-zero.test:20"}
(gdb) p B
$2 = {Sec = 0x2742a8, ForceAbsolute = true, Val = 0, Alignment = 1, Loc = "addr-zero.test:20"}

The returned ExprValue is {A.Sec, false, 0, A.Loc} where A.Sec is .text
(0x38 with this revision, changed to 0x70 later)

I guess this is also related to Config->SingleRoRx . Where the sub
implementation happened to compute the intended value 0 before.

I am unclear how sub should behave. Do ruiu@ grimar@ have some thoughts
here?

>Repository:
>  rLLD LLVM Linker
>
>https://reviews.llvm.org/D45788
>
>
>

-- 
宋方睿


More information about the llvm-commits mailing list