[PATCH] D72194: [MC][ELF] Ensure that mergeable globals with an explicit section are assigned to SHF_MERGE sections with compatible entsizes
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 16 14:46:33 PDT 2020
MaskRay added inline comments.
================
Comment at: llvm/include/llvm/MC/MCContext.h:335
+ // sections (e.g. via _attribute_((section("myname")))).
+ std::set<StringRef> ELFSeenGenericMergeableSections;
+
----------------
MaskRay wrote:
> DenseSet
MCContext::renameELFSection is only used by GNU-style .zdebug_* (GNU-style is obsoleted by SHF_COMPRESSED).
I think we should not add code just to make .zdebug_* happy. Can we simplify code if .zdebug_str is not a big issue?
================
Comment at: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp:737
- SmallString<128> Name;
- if (Kind.isMergeableCString()) {
- // We also need alignment here.
- // FIXME: this is getting the alignment of the character, not the
- // alignment of the global!
- unsigned Align = GO->getParent()->getDataLayout().getPreferredAlignment(
- cast<GlobalVariable>(GO));
-
- std::string SizeSpec = ".rodata.str" + utostr(EntrySize) + ".";
- Name = SizeSpec + utostr(Align);
- } else if (Kind.isMergeableConst()) {
- Name = ".rodata.cst";
- Name += utostr(EntrySize);
- } else {
- Name = getSectionPrefixForGlobal(Kind);
- }
-
- if (const auto *F = dyn_cast<Function>(GO)) {
- const auto &OptionalPrefix = F->getSectionPrefix();
- if (OptionalPrefix)
- Name += *OptionalPrefix;
- }
-
- unsigned UniqueID = MCContext::GenericSectionID;
- if (EmitUniqueSection) {
- if (TM.getUniqueSectionNames()) {
- Name.push_back('.');
- TM.getNameWithPrefix(Name, GO, Mang, true /*MayAlwaysUsePrivate*/);
- } else {
- UniqueID = *NextUniqueID;
- (*NextUniqueID)++;
+ bool UniqueSectionName = false;
+ unsigned UniqueID = MCContext::GenericSectionID;
----------------
Accidentally indented.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72194/new/
https://reviews.llvm.org/D72194
More information about the llvm-commits
mailing list