question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Load binaries with a custom function ordering

See original GitHub issue

I have compiled a binary with relocation flag enabled ld --emit-relocs. Now I want to load the binary with a specific function ordering. I mean I want to give the function order as argument to CLE and CLE should load the binary in that order. Does CLE support this functionality? If doesn’t can you give me some pointers which source files should I look up first to implement this feature for X86_64 ELF binaries.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rhelmotcommented, Nov 6, 2019

I don’t understand this quesiton. What does it mean for a binary to have its functions in a certain order? Do you mean CLE re-linking the binary with the functions arranged in that order in the address space? From what I can tell that’s the point of the --emit-relocs function, but I don’t understand what the use case for this would be.

The most serious roadblock to this would be that CLE absolutely does not have the relocations implemented to do anything other than the stuff that usually shows up in dynamically linked executables. You’ll have to implement all the code relocations yourself (cle/backends/elf/relocation). Then you’ll probably want to build a custom backend which subclasses backends.ELF and after super-init returns, chops up and reorders the text section. I don’t know if the relocations from --emit-relocs will be automatically processed by CLE’s linking step, so if they aren’t you’ll need to inject those somehow as well.

0reactions
github-actions[bot]commented, May 27, 2022

This issue has been closed due to inactivity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I force the order of functions in a binary with the gcc ...
The background is, I have external code which is linked against offsets in this binary. Now if I change the source, all the...
Read more >
How do I add functionality to an existing binary executable?
Whenever an application uses a DLL, and you can tell the load order with Dependency Walker or under a debugger, you can pick...
Read more >
Loading Binary Files in Python that Were Written Using C ...
With the first character of the format string we specify the byte ordering: we're using < to tell the unpack function that the...
Read more >
Azure Functions custom handlers | Microsoft Learn
Custom handlers are lightweight web servers that receive events from the Functions host. Any language that supports HTTP primitives can ...
Read more >
Loading binary data to NumPy/Pandas | by Chris Maierle
In this article, I'll show you how to use a combination of built-in functions, the C-API, and Cython to quickly and easily put...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found