[DwarfGenerator] Emit dwarf address section when dwarf version is not less than 4
authorKai Luo <lkail@cn.ibm.com>
Fri, 10 Feb 2023 03:17:39 +0000 (03:17 +0000)
committerKai Luo <lkail@cn.ibm.com>
Fri, 10 Feb 2023 03:18:18 +0000 (03:18 +0000)
Some targets (like AIX) might not feature dwarf address section due to low dwarf version. Check before emitting one.

Fixed DebugInfo unit test failures in https://lab.llvm.org/buildbot/#/builders/214/builds/5739.

Reviewed By: qiucf

Differential Revision: https://reviews.llvm.org/D143561

llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp

index b683bfb..c5b9f5c 100644 (file)
@@ -582,7 +582,8 @@ StringRef dwarfgen::Generator::generate() {
   StringPool->emit(*Asm, TLOF->getDwarfStrSection(),
                    TLOF->getDwarfStrOffSection());
 
-  AddressPool.emit(*Asm, TLOF->getDwarfAddrSection(), AddrTableStartSym);
+  if (Asm->getDwarfVersion() >= 5)
+    AddressPool.emit(*Asm, TLOF->getDwarfAddrSection(), AddrTableStartSym);
 
   MS->switchSection(TLOF->getDwarfInfoSection());
   for (auto &CU : CompileUnits) {