mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-12 01:58:17 +00:00
Merge pull request #1097 from devnexen/llvm_lto_inst_dict
LLVM LTO plugin using smart pointer for __afl_internal_directory vari…
This commit is contained in:
@ -28,6 +28,7 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <set>
|
#include <set>
|
||||||
@ -1015,13 +1016,7 @@ bool AFLLTOPass::runOnModule(Module &M) {
|
|||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
|
|
||||||
if ((ptr = (char *)malloc(memlen + count)) == NULL) {
|
auto ptrhld = std::unique_ptr<char []>(new char[memlen + count]);
|
||||||
|
|
||||||
fprintf(stderr, "Error: malloc for %zu bytes failed!\n",
|
|
||||||
memlen + count);
|
|
||||||
exit(-1);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
@ -1030,8 +1025,8 @@ bool AFLLTOPass::runOnModule(Module &M) {
|
|||||||
|
|
||||||
if (offset + token.length() < 0xfffff0 && count < MAX_AUTO_EXTRAS) {
|
if (offset + token.length() < 0xfffff0 && count < MAX_AUTO_EXTRAS) {
|
||||||
|
|
||||||
ptr[offset++] = (uint8_t)token.length();
|
ptrhld.get()[offset++] = (uint8_t)token.length();
|
||||||
memcpy(ptr + offset, token.c_str(), token.length());
|
memcpy(ptrhld.get() + offset, token.c_str(), token.length());
|
||||||
offset += token.length();
|
offset += token.length();
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
@ -1051,10 +1046,10 @@ bool AFLLTOPass::runOnModule(Module &M) {
|
|||||||
GlobalVariable *AFLInternalDictionary = new GlobalVariable(
|
GlobalVariable *AFLInternalDictionary = new GlobalVariable(
|
||||||
M, ArrayTy, true, GlobalValue::ExternalLinkage,
|
M, ArrayTy, true, GlobalValue::ExternalLinkage,
|
||||||
ConstantDataArray::get(C,
|
ConstantDataArray::get(C,
|
||||||
*(new ArrayRef<char>((char *)ptr, offset))),
|
*(new ArrayRef<char>(ptrhld.get(), offset))),
|
||||||
"__afl_internal_dictionary");
|
"__afl_internal_dictionary");
|
||||||
AFLInternalDictionary->setInitializer(ConstantDataArray::get(
|
AFLInternalDictionary->setInitializer(ConstantDataArray::get(
|
||||||
C, *(new ArrayRef<char>((char *)ptr, offset))));
|
C, *(new ArrayRef<char>(ptrhld.get(), offset))));
|
||||||
AFLInternalDictionary->setConstant(true);
|
AFLInternalDictionary->setConstant(true);
|
||||||
|
|
||||||
GlobalVariable *AFLDictionary = new GlobalVariable(
|
GlobalVariable *AFLDictionary = new GlobalVariable(
|
||||||
|
Reference in New Issue
Block a user