On Wed, Jan 31, 2024 at 9:10 AM Jakub Jelinek <ja...@redhat.com> wrote: > > On Wed, Jan 31, 2024 at 08:48:33AM -0800, H.J. Lu wrote: > > Which function (target hook) can I use to generate > > > > .section .data.rel.ro.local,"awG",@progbits,_ZN1AIxE3fooExx,comdat > > Just > if (decl) > return get_section (reloc == 1 > ? ".data.rel.ro.local" : ".data.rel.ro", > SECTION_WRITE | SECTION_RELRO | SECTION_LINKONCE, > decl); > for the first hunk and > else if (decl) > return get_section (".rodata", SECTION_LINKONCE, decl); > in the second case? > > Haven't tried it though, maybe the get_section section conflict stuff > isn't able to handle it (and perhaps that is the reason why we simply don't > emit functions into > .section .text,"axG",@progbits,whatever,comdat > sections instead of > .section .text.function_name,"axG",@progbits,whatever,comdat
GNU binutils has no issues with it: [hjl@gnu-cfl-3 tmp]$ cat x.s .section .text,"axG",@progbits,whatever,comdat nop .text nop [hjl@gnu-cfl-3 tmp]$ gcc -c x.s [hjl@gnu-cfl-3 tmp]$ readelf -SW x.o | grep text [ 2] .text PROGBITS 0000000000000000 000048 000001 00 AX 0 0 1 [ 5] .text PROGBITS 0000000000000000 000049 000001 00 AXG 0 0 1 [hjl@gnu-cfl-3 tmp]$ If it doesn't work for some targets, we can use targetm.asm_out.function_rodata_section. > In such case, we could append something to those section names, > like const.pool (or whatever else that couldn't clash with function names, > so needs probably a dot somewhere). Could be > .data.rel.ro.local.const.pool > .data.rel.ro.const.pool > or > .data.rel.ro.local..shared > .data.rel.ro..shared > or something similar, but .data.rel.ro.local.shared would not be ok, > because it could clash with .data.rel.ro.local section for shared function. > > > > Another question is if we need to do anything about the > > > DECL_COMDAT_GROUP (decl) && DECL_SECTION_NAME (decl) > > > && startswith (DECL_SECTION_NAME (decl), ".gnu.linkonce.t.") > > > case (older linkers) (i.e. when using years old GNU linkers). > > > > > > > Should we support such targets? It is not easy for me to test it. > > Perhaps let's wait if somebody files an issue with such configuration. > > Jakub > -- H.J.