Skip to content

Commit a081868

Browse files
author
diggerlin
committed
[AIX][XCOFF] emit symbol visibility for xcoff object file.
SUMMARY: Reviewers: Jason liu Differential Revision: https://reviews.llvm.org/D84265
1 parent 1beb11c commit a081868

File tree

3 files changed

+471
-10
lines changed

3 files changed

+471
-10
lines changed

llvm/include/llvm/MC/MCSectionXCOFF.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ class MCSectionXCOFF final : public MCSection {
6666
XCOFF::StorageClass getStorageClass() const {
6767
return QualName->getStorageClass();
6868
}
69+
70+
XCOFF::VisibilityType getVisibilityType() const {
71+
return QualName->getVisibilityType();
72+
}
73+
6974
XCOFF::SymbolType getCSectType() const { return Type; }
7075
MCSymbolXCOFF *getQualNameSymbol() const { return QualName; }
7176

llvm/lib/MC/XCOFFObjectWriter.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ struct Symbol {
6868
XCOFF::StorageClass getStorageClass() const {
6969
return MCSym->getStorageClass();
7070
}
71+
72+
XCOFF::VisibilityType getVisibilityType() const {
73+
return MCSym->getVisibilityType();
74+
}
75+
7176
StringRef getSymbolTableName() const { return MCSym->getSymbolTableName(); }
7277
Symbol(const MCSymbolXCOFF *MCSym) : MCSym(MCSym), SymbolTableIndex(-1) {}
7378
};
@@ -561,13 +566,12 @@ void XCOFFObjectWriter::writeSymbolTableEntryForCsectMemberLabel(
561566
W.write<uint32_t>(CSectionRef.Address + SymbolOffset);
562567
W.write<int16_t>(SectionIndex);
563568
// Basic/Derived type. See the description of the n_type field for symbol
564-
// table entries for a detailed description. Since we don't yet support
565-
// visibility, and all other bits are either optionally set or reserved, this
566-
// is always zero.
567-
// TODO FIXME How to assert a symbol's visibilty is default?
569+
// table entries for a detailed description. Since we support visibility, and
570+
// all other bits are either optionally set or reserved, we only set bits 0-3
571+
// for symbol's visibility and leave other bits to zero.
568572
// TODO Set the function indicator (bit 10, 0x0020) for functions
569573
// when debugging is enabled.
570-
W.write<uint16_t>(0);
574+
W.write<uint16_t>(SymbolRef.getVisibilityType());
571575
W.write<uint8_t>(SymbolRef.getStorageClass());
572576
// Always 1 aux entry for now.
573577
W.write<uint8_t>(1);
@@ -598,13 +602,12 @@ void XCOFFObjectWriter::writeSymbolTableEntryForControlSection(
598602
// n_scnum
599603
W.write<int16_t>(SectionIndex);
600604
// Basic/Derived type. See the description of the n_type field for symbol
601-
// table entries for a detailed description. Since we don't yet support
602-
// visibility, and all other bits are either optionally set or reserved, this
603-
// is always zero.
604-
// TODO FIXME How to assert a symbol's visibilty is default?
605+
// table entries for a detailed description. Since we support visibility, and
606+
// all other bits are either optionally set or reserved, we only set bits 0-3
607+
// for symbol's visibility and leave other bits to zero.
605608
// TODO Set the function indicator (bit 10, 0x0020) for functions
606609
// when debugging is enabled.
607-
W.write<uint16_t>(0);
610+
W.write<uint16_t>(CSectionRef.MCCsect->getVisibilityType());
608611
// n_sclass
609612
W.write<uint8_t>(StorageClass);
610613
// Always 1 aux entry for now.

0 commit comments

Comments
 (0)