forked from OSchip/llvm-project
Use a name mangler object to uniquify names and remove nonstandard
characters from them. llvm-svn: 22371
This commit is contained in:
parent
93bf2de35b
commit
dfe33bc837
|
@ -35,6 +35,7 @@
|
||||||
#include "llvm/CodeGen/ELFWriter.h"
|
#include "llvm/CodeGen/ELFWriter.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
|
#include "llvm/Support/Mangler.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
ELFWriter::ELFWriter(std::ostream &o, TargetMachine &tm) : O(o), TM(tm) {
|
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
|
// doInitialization - Emit the file header and all of the global variables for
|
||||||
// the module to the ELF file.
|
// the module to the ELF file.
|
||||||
bool ELFWriter::doInitialization(Module &M) {
|
bool ELFWriter::doInitialization(Module &M) {
|
||||||
|
Mang = new Mangler(M);
|
||||||
|
|
||||||
outbyte(0x7F); // EI_MAG0
|
outbyte(0x7F); // EI_MAG0
|
||||||
outbyte('E'); // EI_MAG1
|
outbyte('E'); // EI_MAG1
|
||||||
outbyte('L'); // EI_MAG2
|
outbyte('L'); // EI_MAG2
|
||||||
|
@ -225,6 +228,9 @@ bool ELFWriter::doFinalization(Module &M) {
|
||||||
|
|
||||||
// Free the output buffer.
|
// Free the output buffer.
|
||||||
std::vector<unsigned char>().swap(OutputBuffer);
|
std::vector<unsigned char>().swap(OutputBuffer);
|
||||||
|
|
||||||
|
// Release the name mangler object.
|
||||||
|
delete Mang; Mang = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,8 +252,8 @@ void ELFWriter::EmitSymbolTable() {
|
||||||
SymbolTable[0].NameIdx = 0;
|
SymbolTable[0].NameIdx = 0;
|
||||||
unsigned Index = 1;
|
unsigned Index = 1;
|
||||||
for (unsigned i = 1, e = SymbolTable.size(); i != e; ++i) {
|
for (unsigned i = 1, e = SymbolTable.size(); i != e; ++i) {
|
||||||
// FIXME: USE A MANGLER!!
|
// Use the name mangler to uniquify the LLVM symbol.
|
||||||
const std::string &Name = SymbolTable[i].GV->getName();
|
std::string Name = Mang->getValueName(SymbolTable[i].GV);
|
||||||
|
|
||||||
if (Name.empty()) {
|
if (Name.empty()) {
|
||||||
SymbolTable[i].NameIdx = 0;
|
SymbolTable[i].NameIdx = 0;
|
||||||
|
|
Loading…
Reference in New Issue