This repository has been archived by the owner on Nov 6, 2022. It is now read-only.
forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ELF] Keep st_type for symbol assignment
PR46970: for `alias = aliasee`, the alias can be used in relocation processing and on ARM st_type does affect Thumb interworking. It is thus desirable for the alias to get the same st_type. Note that the st_size field should not be inherited because some tools use st_size=0 as a heuristic to detect aliases. Retaining st_size can thwart such heuristics and cause aliases to be preferred over the original symbols. Differential Revision: https://reviews.llvm.org/D86263 (cherry picked from commit 9670029) The test symbol-assign-type.s was rewritten to not depend on 'split-file'.
- Loading branch information
Showing
6 changed files
with
85 additions
and
5 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# REQUIRES: x86 | ||
## Keep st_type for simple assignment (`alias = aliasee`). This property is | ||
## desired on some targets, where symbol types can affect relocation processing | ||
## (e.g. Thumb interworking). However, the st_size field should not be retained | ||
## because some tools use st_size=0 as a heuristic to detect aliases. With any | ||
## operation, it can be argued that the new symbol may not be of the same type, | ||
## so reset st_type to STT_NOTYPE. | ||
|
||
## NOTE: GNU ld retains st_type for many operations. | ||
|
||
# RUN: echo 'retain1 = _start; \ | ||
# RUN: retain2 = 1 ? _start : 0; \ | ||
# RUN: drop1 = _start + 0; \ | ||
# RUN: drop2 = 0 ? _start : 1; \ | ||
# RUN: drop3 = -_start; \ | ||
# RUN: ' > %t.lds | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o | ||
# RUN: ld.lld -T %t.lds %t.o -o %t1 | ||
# RUN: llvm-readelf -s %t1 | FileCheck %s | ||
|
||
# CHECK: Size Type Bind Vis Ndx Name | ||
# CHECK: 1 FUNC GLOBAL DEFAULT 1 _start | ||
# CHECK: 0 FUNC GLOBAL DEFAULT 1 retain1 | ||
# CHECK-NEXT: 0 FUNC GLOBAL DEFAULT 1 retain2 | ||
# CHECK-NEXT: 0 NOTYPE GLOBAL DEFAULT 1 drop1 | ||
# CHECK-NEXT: 0 NOTYPE GLOBAL DEFAULT ABS drop2 | ||
# CHECK-NEXT: 0 NOTYPE GLOBAL DEFAULT ABS drop3 | ||
|
||
# RUN: ld.lld --defsym 'retain=_start' --defsym 'drop=_start+0' %t.o -o %t2 | ||
# RUN: llvm-readelf -s %t2 | FileCheck %s --check-prefix=DEFSYM | ||
|
||
# DEFSYM: 0 FUNC GLOBAL DEFAULT 1 retain | ||
# DEFSYM-NEXT: 0 NOTYPE GLOBAL DEFAULT 1 drop | ||
|
||
.globl _start | ||
.type _start, @function | ||
_start: | ||
ret | ||
.size _start, 1 |