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

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 15 06:15:24 PDT 2018


grimar added inline comments.


================
Comment at: test/ELF/linkerscript/addr-zero.test:11
 # CHECK:        Name: foo
-# CHECK-NEXT:   Value: 0x0
+# CHECK-NEXT:   Value: 0x38
 # CHECK-NEXT:   Size: 0
----------------
NickHung wrote:
> This change breaks the value of foo.
> The expected value of foo is 0x0.
> 
I think the script should be just changed to

`foo = ADDR(.dynsym) - ABSOLUTE(ADDR(.dynsym));`

where `.dynsym` is the first section now.

The problem with this script seems to be that it tries to evaluate ABSOLUTE value for `.text`
too early. When we assign to `foo` we do not yet know the absolute address of the `.text`.

Before this patch, `.text` was the first section at VA = 0, so this just worked.
Such script would not produce zero value for `foo` with any other
section other than `.text` I believe.

I am not sure (and did not find) what was the initial intention to support script like this.
Perhaps there was some other issue which produced some broken value instead of zero.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D45788





More information about the llvm-commits mailing list