llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

.stack_sizes should interact better with ELF

Open llvmbot opened this issue 8 years ago • 5 comments

Bugzilla Link 36717
Resolution FIXED
Resolved on Feb 19, 2020 11:14
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @bd1976bris,@MaskRay,@jh7370,@wjristow,@wolfy1961

Extended Description

I have noticed a few issues with the current .stack_sizes implementation

1: It can created unaligned relocations:

000000000009 000400000001 R_X86_64_64 0000000000000000 bar + 0

2: The relocations point to global symbols. If bar is weak and resolves to another file this entry will refer to the wrong function.

3: It doesn't produce multiple sections if -function-sections is used.

4: It doesn't take comdats into consideration.

5: It doesn't use SHF_LINK_ORDER for enabling garbage collection by the linker.

The last part requires some work in lld too.

llvmbot avatar Mar 13 '18 23:03 llvmbot

Point 1 is not a problem. Misalignment is fine. Everything has been fixed now, closing.

MaskRay avatar Feb 19 '20 19:02 MaskRay

Problem 1: https://reviews.llvm.org/D74815

(.stack_sizes uses SHF_LINK_ORDER unconditionally, not guarded by -use-integrated-as.

I reported several GNU as and ld feature requests. hjl implemented all of them. binutils>=2.35 will be good.

Link: https://gcc.gnu.org/ml/gcc/2020-01/msg00067.html https://sourceware.org/ml/binutils/2020-02/ )

MaskRay avatar Feb 19 '20 07:02 MaskRay

Item 2 from comment 0 was implemented with r328581.

Items 3, 4, and 5 from comment 0 were implemented with rL335332 and rL335336 respectively.

wolfy1961 avatar Jun 20 '19 00:06 wolfy1961

1: It can created unaligned relocations:

I'm not sure this is a problem. Unaligned relocations are perfectly acceptable. If I'm not mistaken, this is already the case for e.g. debug data.

jh7370 avatar Jun 18 '19 13:06 jh7370

local symbols: https://reviews.llvm.org/D44669.

Comdats: https://reviews.llvm.org/D46874.

See http://lists.llvm.org/pipermail/llvm-dev/2018-March/122180.html for performance concerns and also comments in the above two reviews.

bd1976bris avatar Jun 14 '19 09:06 bd1976bris