Right now .stack-size ends up having relocations that point to global symbols. This means that if the symbol from another file is selected at link time it will be referring to the wrong symbol.
This is a first step in fixing pr36717.
Differential D44669
Use local symbols for creating .stack-size • espindola on Mar 19 2018, 7:03 PM. Authored by
Details
Right now .stack-size ends up having relocations that point to global symbols. This means that if the symbol from another file is selected at link time it will be referring to the wrong symbol. This is a first step in fixing pr36717.
Diff Detail Event TimelineComment Actions No, in practice the assembler will convert the relocations to use section symbols instead. Comment Actions Hi Rafael. The SN-Linker has the following rule for metadata sections: Relocations from "metadata sections" to global symbols are I have mentioned this rule here: https://groups.google.com/d/msg/generic-abi/A-1rbP8hFCA/z2xHWFQBCAAJ It would be an obvious extension to your SHF_LINK_ORDER concept. What do you think? Comment Actions I agree with Cary that it is a bad idea to break sections. What is needed is a liker like lld that is efficient at handling sections.
It is not an obvious extension. The obvious solution is to just use multiple sections. I am sorry I missed this when it went in, but we should never add an extension that requires a section that refers to multiple ones. I will fix llvm to use multiple sections for -ffunction-sections/comdat next. And there is no local symbol pouting the output. The assembler will convert the reference to use section symbols. Comment Actions Hi Rafael, Thanks for the reply. I agree that multiple sections is conceptually a
I agree with this and with the rest of your assessment in pr36717.
convert the reference to use section symbols. I understand that and I thought your change was good. Apologies, Comment Actions
Why are extra symbols *in the assembly* a problem? We normally don't print assembly and using local symbols means that we have only one place that has to implement the logic for using section symbols in relocations. I quite like the rule: CodeGen and user written assembly files use local symbols everywhere and the assembler optimizes that when possible. Having said that, if you really find the assembly verbosity problematic, getFunctionBegin could return a section symbol when the current function is at the start of a section. Comment Actions
I suppose I like the assembly to look good :) I think that the first of the .globl _start _start: ret .section ".stack_sizes","",@progbits .quad _start .uleb128 10 .globl _start _start: .L_start: ret .section ".stack_sizes","",@progbits .quad .L_start .uleb128 10 .globl first first: ret .globl _start _start: ret .section ".stack_sizes","",@progbits .quad .text+10 .uleb128 10
This sounds like a sound design choice to me. (Although, I have to say that
This would certainly remove the extra local symbols. I like the purity of Comment Actions Given that some people like to post-process assembler files, using the section symbol directly is a bad idea. Adding the local symbols is fine. |