dvyukov added a comment.

@melver Re this failure:

  ******************** TEST 'Clang :: 
Instrumentation/SanitizerBinaryMetadata/uar.cpp' FAILED ********************
  Script:
  --
  : 'RUN: at line 4';   
/home/buildbot/as-worker-91/clang-with-lto-ubuntu/build/stage1/bin/clang 
--driver-mode=g++ 
/home/buildbot/as-worker-91/clang-with-lto-ubuntu/llvm-project/clang/test/Instrumentation/SanitizerBinaryMetadata/uar.cpp
 -o 
/home/buildbot/as-worker-91/clang-with-lto-ubuntu/build/stage1/tools/clang/test/Instrumentation/SanitizerBinaryMetadata/Output/uar.cpp.tmp
 -fexperimental-sanitize-metadata=covered,uar && 
/home/buildbot/as-worker-91/clang-with-lto-ubuntu/build/stage1/tools/clang/test/Instrumentation/SanitizerBinaryMetadata/Output/uar.cpp.tmp
 | /home/buildbot/as-worker-91/clang-with-lto-ubuntu/build/stage1/bin/FileCheck 
/home/buildbot/as-worker-91/clang-with-lto-ubuntu/llvm-project/clang/test/Instrumentation/SanitizerBinaryMetadata/uar.cpp
  --
  Exit Code: 1
  Command Output (stderr):
  --
  /usr/local/bin/ld: sanmd_covered has both ordered 
[`sanmd_covered[_Z7consumeIjET_RPKcS2_]' in /tmp/lit-tmp-2jisr97l/uar-d5d8d4.o] 
and unordered [`sanmd_covered[__dummy_sanmd_covered]' in 
/tmp/lit-tmp-2jisr97l/uar-d5d8d4.o] sections
  /usr/local/bin/ld: final link failed: Bad value
  clang-16: error: linker command failed with exit code 1 (use -v to see 
invocation)

https://lab.llvm.org/buildbot/#/builders/124/builds/5759/steps/7/logs/stdio

This looks like a latent issue which is just exposed by the test.

As far as I understand this happens because this dummy variable somehow ends up 
in an "unordered" section, while other "real" metadata objects end up in 
"ordered" sections:

  void SanitizerBinaryMetadata::createZeroSizedObjectInSection(
      Type *Ty, StringRef SectionSuffix) {
    auto *DummyInit = ConstantAggregateZero::get(ArrayType::get(Ty, 0));
    auto *DummyEntry = new GlobalVariable(Mod, DummyInit->getType(), true,
                                          GlobalVariable::ExternalLinkage,
                                          DummyInit, "__dummy_" + 
SectionSuffix);
    DummyEntry->setSection(getSectionName(SectionSuffix));
    DummyEntry->setVisibility(GlobalValue::HiddenVisibility);
    if (TargetTriple.supportsCOMDAT())
      DummyEntry->setComdat(Mod.getOrInsertComdat(DummyEntry->getName()));
    // Make sure the section isn't discarded by gc-sections.
    appendToUsed(Mod, DummyEntry);
  }

I don't see any method on GlobalVariable to set the section to "ordered".

The only idea I have is to print dummy object in AsmPrinter the same way we 
print all other metadata objects (then I assume it will have the same 
properties as other objects).

Do you have any other ideas on how to dead with this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136078/new/

https://reviews.llvm.org/D136078

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to