================
@@ -1266,23 +1266,42 @@ MCObjectFileInfo::getStackSizesSection(const MCSection
&TextSec) const {
MCSection *
MCObjectFileInfo::getBBAddrMapSection(const MCSection &TextSec) const {
- if (Ctx->getObjectFileType() != MCContext::IsELF)
- return nullptr;
+ constexpr StringLiteral Name = ".llvm_bb_addr_map";
+ if (Ctx->getObjectFileType() == MCContext::IsELF) {
+ const MCSectionELF &ElfSec = static_cast<const MCSectionELF &>(TextSec);
+ unsigned Flags = ELF::SHF_LINK_ORDER;
+ StringRef GroupName;
+ if (const MCSymbol *Group = ElfSec.getGroup()) {
+ GroupName = Group->getName();
+ Flags |= ELF::SHF_GROUP;
+ }
- const MCSectionELF &ElfSec = static_cast<const MCSectionELF &>(TextSec);
- unsigned Flags = ELF::SHF_LINK_ORDER;
- StringRef GroupName;
- if (const MCSymbol *Group = ElfSec.getGroup()) {
- GroupName = Group->getName();
- Flags |= ELF::SHF_GROUP;
+ // Use the text section's begin symbol and unique ID to create a separate
+ // .llvm_bb_addr_map section associated with every unique text section.
+ return Ctx->getELFSection(
+ Name, ELF::SHT_LLVM_BB_ADDR_MAP, Flags, 0, GroupName, true,
+ ElfSec.getUniqueID(),
+ static_cast<const MCSymbolELF *>(TextSec.getBeginSymbol()));
+ } else if (Ctx->getObjectFileType() == MCContext::IsCOFF) {
+ StringRef COMDATSymName = "";
+ int Selection = 0;
+ unsigned Characteristics = COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
+ COFF::IMAGE_SCN_MEM_DISCARDABLE |
+ COFF::IMAGE_SCN_MEM_READ;
+ const auto &COFFSec = static_cast<const MCSectionCOFF &>(TextSec);
+ if (const MCSymbol *COMDATSym = COFFSec.getCOMDATSymbol()) {
+ if (!Ctx->getAsmInfo()->hasCOFFAssociativeComdats())
+ report_fatal_error("BB address map requires associative COMDAT "
+ "support for COMDAT functions");
+ COMDATSymName = COMDATSym->getName();
----------------
HaohaiWen wrote:
The current approach allows non-COMDAT functions to work on MinGW while clearly
reporting unsupported COMDAT cases
https://github.com/llvm/llvm-project/pull/191347
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits