|
93 | 93 | #include "llvm/MC/MCSectionCOFF.h" |
94 | 94 | #include "llvm/MC/MCSectionELF.h" |
95 | 95 | #include "llvm/MC/MCSectionMachO.h" |
| 96 | +#include "llvm/MC/MCSectionXCOFF.h" |
96 | 97 | #include "llvm/MC/MCStreamer.h" |
97 | 98 | #include "llvm/MC/MCSubtargetInfo.h" |
98 | 99 | #include "llvm/MC/MCSymbol.h" |
@@ -444,7 +445,7 @@ bool AsmPrinter::doInitialization(Module &M) { |
444 | 445 | .getModuleMetadata(M); |
445 | 446 |
|
446 | 447 | // On AIX, we delay emitting any section information until |
447 | | - // after emitting the .file pseudo-op. This allows additional |
| 448 | + // after emitting the .file pseudo-op. This allows additional |
448 | 449 | // information (such as the embedded command line) to be associated |
449 | 450 | // with all sections in the object file rather than a single section. |
450 | 451 | if (!TM.getTargetTriple().isOSBinFormatXCOFF()) |
@@ -496,8 +497,18 @@ bool AsmPrinter::doInitialization(Module &M) { |
496 | 497 | // C_INFO symbol is preserved if any csect is kept by the linker. |
497 | 498 | if (TM.getTargetTriple().isOSBinFormatXCOFF()) { |
498 | 499 | emitModuleCommandLines(M); |
499 | | - // Now we can generate section information |
| 500 | + // Now we can generate section information. |
500 | 501 | OutStreamer->initSections(false, *TM.getMCSubtargetInfo()); |
| 502 | + |
| 503 | + // To work around an AIX assembler and/or linker bug, generate |
| 504 | + // a rename for the default text-section symbol name. This call has |
| 505 | + // no effect when generating object code directly. |
| 506 | + MCSection *TextSection = |
| 507 | + OutStreamer->getContext().getObjectFileInfo()->getTextSection(); |
| 508 | + MCSymbolXCOFF *XSym = |
| 509 | + static_cast<MCSectionXCOFF *>(TextSection)->getQualNameSymbol(); |
| 510 | + if (XSym->hasRename()) |
| 511 | + OutStreamer->emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName()); |
501 | 512 | } |
502 | 513 |
|
503 | 514 | GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>(); |
|
0 commit comments