Coder Social home page Coder Social logo

Error while lifting. about llvm-mctoll HOT 6 CLOSED

anzosasuke avatar anzosasuke commented on May 24, 2024
Error while lifting.

from llvm-mctoll.

Comments (6)

bharadwajy avatar bharadwajy commented on May 24, 2024 1

Thanks. But i am still getting the same error after that.

``llvm-mctoll: /data/llvm-project/llvm/tools/llvm-mctoll/X86/X86MachineInstructionRaiserUtils.cpp:1531: llvm::Function* llvm::mctoll::X86MachineInstructionRaiser::getTargetFunctionAtPLTOffset(const llvm::MachineInstr&, uint64_t): Assertion `(GotPltReloc->getType() == ELF::R_X86_64_JUMP_SLOT) && "Unexpected relocation type for PLT jmp instruction"' failed.

It appears that you need to pull the llvm-mctoll repo as that line has been part of the change I pushed - see here. Rebuild llvm-mctoll once you update your llvm-mctoll repo.

I have verified that the change works using the sclang binary you provided earlier before I pushed.

from llvm-mctoll.

bharadwajy avatar bharadwajy commented on May 24, 2024 1

Thanks so much. It worked. I was just pulling llvm project instead of llvm-mctoll. But i am getting this:

Unknown prototype for function : strcmp
Use -I </full/path/to/file>, where /full/path/to/file declares its prototype

Do we need the include file to get the llvm IR? If we actually need to put it, does that mean some portion of source is needed to lift binary to IR? and when using the command "llvm-mctoll -d " yield the result in the interface itself?

You do not need any portion of the source file. You will need to provide the prototypes of externally linked functions (such as strcmp) for llvm-mctoll to help the process of raising as described here. llvm-mctoll cannot figure out the prototypes of externally linked functions just using the binary.

For example, here is a portion of the file I created with external (i.e., glibc) function prototypes to ensure that the tool makes progress beyond the assertion fix I made while raising your binary.

$ cat myinclude.h
#include <stddef.h>

int strcmp(const char *s1, const char *s2);
int strncmp(const char *s1, const char *s2, size_t n);
char *strcpy(char *dest, const char *src);
size_t strlen(const char *s);
char *strndup(const char *s, size_t n);
char *strdup(const char *s);

$ llvm-mctoll -d -I /full/path/to/myinclude.h sclang

Please note that I have not added all the necessary prototypes. Please add any additional prototypes to check if your sclang binary can be raised by llvm-mctoll.

from llvm-mctoll.

bharadwajy avatar bharadwajy commented on May 24, 2024

Thanks for your interest in the project.

I have pushed a change to relax the assertion to handle the relocation type R_X86_64_GLOB_DAT.

Let me know if that helps.

from llvm-mctoll.

anzosasuke avatar anzosasuke commented on May 24, 2024

Thanks. But i am still getting the same error after that.

``llvm-mctoll: /data/llvm-project/llvm/tools/llvm-mctoll/X86/X86MachineInstructionRaiserUtils.cpp:1531: llvm::Function* llvm::mctoll::X86MachineInstructionRaiser::getTargetFunctionAtPLTOffset(const llvm::MachineInstr&, uint64_t): Assertion `(GotPltReloc->getType() == ELF::R_X86_64_JUMP_SLOT) && "Unexpected relocation type for PLT jmp instruction"' failed.

*** Please submit an issue at https://github.com/microsoft/llvm-mctoll
*** along with a back trace and a reproducer, if possible.
Stack dump:
0. Program arguments: ./llvm-mctoll -d sclang
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var LLVM_SYMBOLIZER_PATH to point to it):
0 llvm-mctoll 0x0000558dac9fca56
1 llvm-mctoll 0x0000558dac9fa43e
2 libc.so.6 0x00007f59c9caf520
3 libc.so.6 0x00007f59c9d03a7c pthread_kill + 300
4 libc.so.6 0x00007f59c9caf476 raise + 22
5 libc.so.6 0x00007f59c9c957f3 abort + 211
6 libc.so.6 0x00007f59c9c9571b
7 libc.so.6 0x00007f59c9ca6e96
8 llvm-mctoll 0x0000558dad04c36b
9 llvm-mctoll 0x0000558dad063c6f
10 llvm-mctoll 0x0000558dad02c3cd
11 llvm-mctoll 0x0000558dac19f51d
12 llvm-mctoll 0x0000558dac13f942
13 libc.so.6 0x00007f59c9c96d90
14 libc.so.6 0x00007f59c9c96e40 __libc_start_main + 128
15 llvm-mctoll 0x0000558dac18d1c5
Aborted (core dumped)


I have attached the file at the top if you want to recreate.

from llvm-mctoll.

anzosasuke avatar anzosasuke commented on May 24, 2024

Thanks so much. It worked. I was just pulling llvm project instead of llvm-mctoll. But i am getting this:

Unknown prototype for function : strcmp
Use -I </full/path/to/file>, where /full/path/to/file declares its prototype

Do we need the include file to get the llvm IR? If we actually need to put it, does that mean some portion of source is needed to lift binary to IR? and when using the command "llvm-mctoll -d " yield the result in the interface itself?

from llvm-mctoll.

anzosasuke avatar anzosasuke commented on May 24, 2024

Got it. Thanks so much.

from llvm-mctoll.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.