Skip to content

Commit 06a895f

Browse files
MaskRayyuxuanchen1997
authored andcommitted
MCAssembler: Move Symvers to ELFObjectWriter
Summary: Similar to c473e75 Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251465
1 parent 69a9a3b commit 06a895f

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

llvm/include/llvm/MC/MCAssembler.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,6 @@ class MCAssembler {
140140
handleFixup(MCFragment &F, const MCFixup &Fixup, const MCSubtargetInfo *STI);
141141

142142
public:
143-
struct Symver {
144-
SMLoc Loc;
145-
const MCSymbol *Sym;
146-
StringRef Name;
147-
// True if .symver *, *@@@* or .symver *, *, remove.
148-
bool KeepOriginalSym;
149-
};
150-
std::vector<Symver> Symvers;
151-
152143
/// Construct a new assembler instance.
153144
//
154145
// FIXME: How are we going to parameterize this? Two obvious options are stay

llvm/include/llvm/MC/MCELFObjectWriter.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LLVM_MC_MCELFOBJECTWRITER_H
1111

1212
#include "llvm/ADT/DenseMap.h"
13+
#include "llvm/ADT/SmallVector.h"
1314
#include "llvm/BinaryFormat/ELF.h"
1415
#include "llvm/MC/MCObjectWriter.h"
1516
#include "llvm/MC/MCSectionELF.h"
@@ -163,6 +164,15 @@ class ELFObjectWriter : public MCObjectWriter {
163164
bool SeenGnuAbi = false;
164165
std::optional<uint8_t> OverrideABIVersion;
165166

167+
struct Symver {
168+
SMLoc Loc;
169+
const MCSymbol *Sym;
170+
StringRef Name;
171+
// True if .symver *, *@@@* or .symver *, *, remove.
172+
bool KeepOriginalSym;
173+
};
174+
SmallVector<Symver, 0> Symvers;
175+
166176
ELFObjectWriter(std::unique_ptr<MCELFObjectTargetWriter> MOTW)
167177
: TargetObjectWriter(std::move(MOTW)) {}
168178

llvm/lib/MC/ELFObjectWriter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,7 @@ void ELFObjectWriter::reset() {
11621162
OverrideABIVersion.reset();
11631163
Relocations.clear();
11641164
Renames.clear();
1165+
Symvers.clear();
11651166
MCObjectWriter::reset();
11661167
}
11671168

@@ -1172,7 +1173,7 @@ bool ELFObjectWriter::hasRelocationAddend() const {
11721173
void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm) {
11731174
// The presence of symbol versions causes undefined symbols and
11741175
// versions declared with @@@ to be renamed.
1175-
for (const MCAssembler::Symver &S : Asm.Symvers) {
1176+
for (const Symver &S : Symvers) {
11761177
StringRef AliasName = S.Name;
11771178
const auto &Symbol = cast<MCSymbolELF>(*S.Sym);
11781179
size_t Pos = AliasName.find('@');

llvm/lib/MC/MCELFStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ void MCELFStreamer::emitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
314314
void MCELFStreamer::emitELFSymverDirective(const MCSymbol *OriginalSym,
315315
StringRef Name,
316316
bool KeepOriginalSym) {
317-
getAssembler().Symvers.push_back(MCAssembler::Symver{
317+
getWriter().Symvers.push_back(ELFObjectWriter::Symver{
318318
getStartTokLoc(), OriginalSym, Name, KeepOriginalSym});
319319
}
320320

0 commit comments

Comments
 (0)