aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/ELFWriter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-07-11 03:11:47 +0000
committerChris Lattner <sabre@nondot.org>2005-07-11 03:11:47 +0000
commit5acd120078bb7356d0c1792f293255bbded9c4c9 (patch)
treec61375531c0c3bdeaff57b6dd225b0b1df6cf188 /lib/CodeGen/ELFWriter.cpp
parent75bbdff3d3318d5b1e1db7469c8b7d7346f71972 (diff)
Use a name mangler object to uniquify names and remove nonstandard
characters from them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22371 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/ELFWriter.cpp')
-rw-r--r--lib/CodeGen/ELFWriter.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp
index a25fbddee3..bdf38fe643 100644
--- a/lib/CodeGen/ELFWriter.cpp
+++ b/lib/CodeGen/ELFWriter.cpp
@@ -35,6 +35,7 @@
#include "llvm/CodeGen/ELFWriter.h"
#include "llvm/Module.h"
#include "llvm/Target/TargetMachine.h"
+#include "llvm/Support/Mangler.h"
using namespace llvm;
ELFWriter::ELFWriter(std::ostream &o, TargetMachine &tm) : O(o), TM(tm) {
@@ -48,6 +49,8 @@ ELFWriter::ELFWriter(std::ostream &o, TargetMachine &tm) : O(o), TM(tm) {
// doInitialization - Emit the file header and all of the global variables for
// the module to the ELF file.
bool ELFWriter::doInitialization(Module &M) {
+ Mang = new Mangler(M);
+
outbyte(0x7F); // EI_MAG0
outbyte('E'); // EI_MAG1
outbyte('L'); // EI_MAG2
@@ -225,6 +228,9 @@ bool ELFWriter::doFinalization(Module &M) {
// Free the output buffer.
std::vector<unsigned char>().swap(OutputBuffer);
+
+ // Release the name mangler object.
+ delete Mang; Mang = 0;
return false;
}
@@ -246,8 +252,8 @@ void ELFWriter::EmitSymbolTable() {
SymbolTable[0].NameIdx = 0;
unsigned Index = 1;
for (unsigned i = 1, e = SymbolTable.size(); i != e; ++i) {
- // FIXME: USE A MANGLER!!
- const std::string &Name = SymbolTable[i].GV->getName();
+ // Use the name mangler to uniquify the LLVM symbol.
+ std::string Name = Mang->getValueName(SymbolTable[i].GV);
if (Name.empty()) {
SymbolTable[i].NameIdx = 0;