-
Notifications
You must be signed in to change notification settings - Fork 733
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ELF][RISCV] Assign st_shndx of __global_pointer$ to 1 if .sdata does…
… not exist This essentially reverts the code change of D63132 and switches to a simpler approach. In an executable/shared object, st_shndx of a symbol can be: 1) SHN_UNDEF: undefined symbol (or canonical PLT) 2) SHN_ABS: absolute symbol 3) any other value (usually a regular section index) represents a relative symbol. The actual value does not matter. Many ld.so (musl, all archs except MIPS of FreeBSD rtld-elf) even treat 2) and 3) the same. If .sdata does not exist, it does not matter what value/section __global_pointer$ has, as long as it is relative (otherwise there will be a pedantic lld error. See D63132). Just set the st_shndx arbitrarily to 1. Dummy st_shndx=1 may be used by __rela_iplt_start, linker-script-defined symbols outside a section, __dso_handle, etc. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D66798 llvm-svn: 370172
- Loading branch information
Showing
5 changed files
with
24 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# REQUIRES: riscv | ||
# RUN: llvm-mc -filetype=obj -triple=riscv32 %s -o %t.32.o | ||
# RUN: ld.lld -pie %t.32.o -o %t.32 | ||
# RUN: llvm-readelf -s %t.32 | FileCheck --check-prefix=SYM %s | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=riscv64 %s -o %t.64.o | ||
# RUN: ld.lld -pie %t.64.o -o %t.64 | ||
# RUN: llvm-readelf -s %t.64 | FileCheck --check-prefix=SYM %s | ||
|
||
## If there is an undefined reference to __global_pointer$ but .sdata doesn't | ||
## exist, define __global_pointer$ and set its st_shndx arbitrarily to 1. | ||
|
||
# SYM: {{0*}}00000800 0 NOTYPE GLOBAL DEFAULT 1 __global_pointer$ | ||
|
||
lla gp, __global_pointer$ |