<div dir="ltr">Hi,<div><br></div><div>I wanted to see if there was a way in IR to emit a local alias such that I would get:</div><div><br></div><div>```</div><div>        .type   _ZTVSt13bad_exception,@object # @_ZTVSt13bad_exception<br>        .globl  _ZTVSt13bad_exception<br>_ZTVSt13bad_exception:</div><div><b>.L_ZTVSt13bad_exception:</b><br>        .long   0                       # 0x0<br>        .long   (_ZTISt13bad_exception.rtti_proxy-.L_ZTVSt13bad_exception)-8<br>        .long   (_ZNSt13bad_exceptionD2Ev.stub@PLT-.L_ZTVSt13bad_exception)-8<br>        .long   (_ZNSt13bad_exceptionD0Ev.stub@PLT-.L_ZTVSt13bad_exception)-8<br>        .long   (_ZNKSt13bad_exception4whatEv.stub@PLT-.L_ZTVSt13bad_exception)-8<br>```<br></div><div><br></div><div>rather than:</div><div><br></div><div>```</div><div>        .type   _ZTVSt13bad_exception,@object # @_ZTVSt13bad_exception<br>        .globl  _ZTVSt13bad_exception<br>_ZTVSt13bad_exception:<br>        .long   0                       # 0x0<br>        .long   (_ZTISt13bad_exception.rtti_proxy-.L_ZTVSt13bad_exception)-8<br>        .long   (_ZNSt13bad_exceptionD2Ev.stub@PLT-.L_ZTVSt13bad_exception)-8<br>        .long   (_ZNSt13bad_exceptionD0Ev.stub@PLT-.L_ZTVSt13bad_exception)-8<br>        .long   (_ZNKSt13bad_exception4whatEv.stub@PLT-.L_ZTVSt13bad_exception)-8<br><br><b>.set .L_ZTVSt13bad_exception, _ZTVSt13bad_exception</b><br></div><div>```</div><div><br></div><div>The latter is what's generated when using a GlobalAlias with private linkage. I'm asking because in either case, I want to be able to place _ZTVSt13bad_exception in .rodata instead of .<a href="http://data.rel.ro">data.rel.ro</a> which requires that the object does not need a relocation.</div><div><br></div><div>According to `Constant::needsRelocation()`, a reloc isn't needed if the offset I'm taking (.long symbol_A - symbol_B) contains symbols that are both dso_local. I can guarantee that `symbol_A` will be, but `symbol_B` needs to be a global with default visibility. My solution around this is to emit a local alias, but the issue is that with optimizations (-O3), the latter snippet seems to "resolve" the aliases and instead replaces them with my aliasee (_ZTVSt13bad_exception) which is not dso_local. An alternative solution to my problem would also be finding a way to somehow prevent the aliases from being "optimized out".</div><div><br></div><div>Any ideas on either (1) IR that can codegen into my first snippet or (2) prevent my alias in the second snippet from being "optimized out"?</div><div><br></div><div>- Leonard</div></div>