2002-04-07 22:49:59 +02:00
|
|
|
//===- SymbolStripping.cpp - Strip symbols for functions and modules ------===//
|
2003-10-20 21:43:21 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-06-06 22:29:01 +02:00
|
|
|
//
|
|
|
|
// This file implements stripping symbols out of symbol tables.
|
|
|
|
//
|
|
|
|
// Specifically, this allows you to strip all of the symbols out of:
|
2002-04-07 22:49:59 +02:00
|
|
|
// * All functions in a module
|
2004-01-10 22:36:49 +01:00
|
|
|
// * All non-essential symbols in a module (all function symbols + all module
|
|
|
|
// scope symbols)
|
2001-06-06 22:29:01 +02:00
|
|
|
//
|
|
|
|
// Notice that:
|
|
|
|
// * This pass makes code much less readable, so it should only be used in
|
|
|
|
// situations where the 'strip' utility would be used (such as reducing
|
|
|
|
// code size, and making it harder to reverse engineer code).
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2002-05-07 22:03:00 +02:00
|
|
|
#include "llvm/Transforms/Scalar.h"
|
2001-06-06 22:29:01 +02:00
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/SymbolTable.h"
|
2002-02-26 22:46:54 +01:00
|
|
|
#include "llvm/Pass.h"
|
2003-11-22 02:29:35 +01:00
|
|
|
using namespace llvm;
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2002-02-26 22:46:54 +01:00
|
|
|
namespace {
|
2002-04-27 08:56:12 +02:00
|
|
|
struct SymbolStripping : public FunctionPass {
|
2002-06-25 18:13:24 +02:00
|
|
|
virtual bool runOnFunction(Function &F) {
|
2004-05-25 10:51:25 +02:00
|
|
|
return F.getSymbolTable().strip();
|
2002-02-26 22:46:54 +01:00
|
|
|
}
|
2002-04-28 23:27:06 +02:00
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesAll();
|
|
|
|
}
|
2002-02-26 22:46:54 +01:00
|
|
|
};
|
2002-07-26 23:12:46 +02:00
|
|
|
RegisterOpt<SymbolStripping> X("strip", "Strip symbols from functions");
|
2002-02-26 22:46:54 +01:00
|
|
|
|
|
|
|
struct FullSymbolStripping : public SymbolStripping {
|
2002-06-25 18:13:24 +02:00
|
|
|
virtual bool doInitialization(Module &M) {
|
2004-05-25 10:51:25 +02:00
|
|
|
return M.getSymbolTable().strip();
|
2002-02-26 22:46:54 +01:00
|
|
|
}
|
|
|
|
};
|
2002-07-26 23:12:46 +02:00
|
|
|
RegisterOpt<FullSymbolStripping> Y("mstrip",
|
|
|
|
"Strip symbols from module and functions");
|
2002-02-26 22:46:54 +01:00
|
|
|
}
|
|
|
|
|
2004-09-20 06:43:15 +02:00
|
|
|
FunctionPass *llvm::createSymbolStrippingPass() {
|
2002-02-26 22:46:54 +01:00
|
|
|
return new SymbolStripping();
|
|
|
|
}
|
|
|
|
|
2004-09-20 06:43:15 +02:00
|
|
|
FunctionPass *llvm::createFullSymbolStrippingPass() {
|
2002-02-26 22:46:54 +01:00
|
|
|
return new FullSymbolStripping();
|
|
|
|
}
|