_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
PE-centric naming is fine. ELF GRP_COMDAT was inspired by PE/COFF so
modeling comdat with COFF is justified :)
>$ cat t.cpp
>int f();
>static int gv = f();
>
>$ clang -S t.cpp --target=x86_64-windows-msvc -o - -emit-llvm
>-fsanitize=address
>...
>$gv = comdat noduplicates
>...
>@gv = internal global { i32, [60 x i8] } zeroinitializer, comdat, align 32
>...
>@__asan_global_gv = private global { i64, i64, i64, i64, i64, i64, i64, i64
>} { i64 ptrtoint ({ i32, [60 x i8] }* @gv to i64), i64 4, i64 64, i64
>ptrtoint ([3 x i8]* @___asan_gen_.1 to i64), i64 ptrtoint ([6 x i8]*
>@___asan_gen_ to i64), i64 1, i64 ptrtoint ({ [6 x i8]*, i32, i32 }*
>@___asan_gen_.3 to i64), i64 -1 }, section ".ASAN$GL", comdat($gv), align
>64, !associated !0
>
>
>We are using the "noduplicates" comdat flag here, but @gv has internal
>linkage, and COFF linkers merge symbols, not section group names, so this
>code does what we want it to. Maybe it would make more sense if we used
>some kind of portable flag, like "internal" or "unique" on the comdat group
>to indicate that the group doesn't participate in merging. On COFF, we'd
>have the limitation that this feature only works for comdat groups named
>after internal linkage globals, but on ELF, the group could have any name.
Yes, looks like ELF's zero section group flag can just reuse `comdat noduplicates`.
>You could rename the Comdat class to Group or SectionGroup or something,
>but I'm not sure there's much value in it. The terminology as it is makes
>sense for COFF, if not for ELF. ELF makes the distinction between comdat
>section groups and non-comdat section groups, but MSVC and clang-cl use the
>IMAGE_SCN_COMDAT symbol flag and the IMAGE_COMDAT_SELECT_ASSOCIATIVE
>selection flag to implement these types of groups.
Start OT now.
It is somewhat awkward that the section header has the
IMAGE_SCN_LNK_COMDAT flag while the selection record is specified as an
auxiliary symbol record.
In ELF, to encode symbol table related information. A new section is
needed (64 bytes for the section header).
IIUC PE/COFF needs a section header (40 bytes). But to represent
association whether no new section/symbol is needed, an auxiliary symbol
record can be used (18 bytes). If the number of the interconnected
sections is small, the cost can be smaller than adding a new section
header.