Convert bytecode to opcode using web3j - web3-java

I can't find any documentation on this, is there a converter from bytecode to opcode inside web3j? Or do I need to build one myself?

In case anyone is looking for a Java implementation, as it doesn't exist in web3j:
https://github.com/fergarrui/ethereum-disassembler

Related

lldb equivalent to (gdb) set target-charset?

In gdb I can switch between different character set encodings (ASCII and EBCDIC say) using commands like:
(gdb) set target-charset EBCDIC
(gdb) set target-charset ASCII
Does lldb have this sort of functionality (perhaps undocumented)?
If not, looking at the advanced python integration available in lldb, I'd guess the best way to implement this would be with a python method. Would anybody be able to point me to a sample python script where the display of a given type is specialized that I could adapt in this respect.
There isn't such a feature, lldb assumes ASCII.
You can add a custom summary from Python to present values of a given type any way you want. This is discussed here:
http://lldb.llvm.org/varformats.html
There are a handful of summary examples here:
https://github.com/llvm/llvm-project/tree/main/lldb/examples/summaries
and you'll also want to consult the SB API documentation, which is here:
http://lldb.llvm.org/python_reference/index.html

IAR Dependency graph

I'm using IAR Embedded Workbench for ARM Cortex-M3 programming. The library I have to use is huge and I need a dependency graph to understand some parts. Can IAR create it or give me a useful report from a compiled code?
Thanks
Behnam
Have you tried giving the --dependencies option directly to the IAR compiler?
You should be able to take that output and use it to generate a dependency graph with, say, graphviz. If you use the --dependencies=m variant, then you will get a makefile-like output which will give you each header file required by each object file.
The IAR compiler manual is here; --dependencies is described on p 132
There's also makegrapher, which, if not exactly what you're after might be a good starting point :D
(Please excuse the delay in reply - I actually found your question while searching for answers to my own about using --dependencies!)

How to extract C source code from .so file?

I am working on previously developed software and source code is compiled as linux shared libraries (.so) and source code is not present. Is there any tool which can extract source code from the linux shared libraries?
Thanks,
Ravi
There isn't. Once you compile your code there is no trace of it left in the binary, only machine code.
Some may mention decompilers but those don't extract the source, they analyze the executable and produce some source that should have the same effect as the original one did.
You can try disassembling the object code and get the machine code mnemonics.
objdump -D --disassembler-options intel sjt.o to get Intel syntax assembly
objdump -D --disassembler-options att sjt.o or objdump -D sjt.o to get AT&T syntax assembly
But the original source code could never be found. You might try to reverse the process by studying and reconstruct the sections. It would be hell pain.
Disclaimer: I work for Hex-Rays SA.
The Hex-Rays decompiler is the only commercially available decompiler I know of that works well with real-life x86 and ARM code. It's true that you don't get the original source, but you get something which is equivalent to it. If you didn't strip your binary, you might even get the function names, or, with some luck, even types and local variables. However, even if you don't have symbol info, you don't have to stick to the first round of decompilation. The Hex-Rays decompiler is interactive - you can rename any variable or function, change variable types, create structure types to represent the structures in the original code, add comments and so on. With a little work you can recover a lot. And quite often what you need is not the whole original file, but some critical algorithm or function - and this Hex-Rays can usually provide to you.
Have a look at the demo videos and the comparison pages. Still think "staring at the assembly" is the same thing?
No. In general, this is impossible. Source is not packaged in compiled objects or libraries.
You cannot. But you can open it as an archive in 7-Zip. You can see the file type and size of each file separately in that. You can replace the files in it with your custom files.

How to write a linker

I have written a compiler for C that outputs byte code. The reason for this was to be able to write applications for an embedded platform that runs on multiple platforms.
I have the compiler and the assembler.
I need to write a linker, and am stuck.
The object format is a custom one, designed around the byte code interpreter, so I cant really use any existing linkers.
My biggest hurdle is how to organize the object code to output the linked binary.
Dynamic linking is not necessary, at this time.
I need to get static linking working first.
Ian Lance Taylor, one of the main developers on the gold linker(now part of binutils), posted a series of blogs on how linkers work. You can find it here.
http://linker.iecc.com is the only book I know about this subject.
I second the Linkers and Loaders book. You state that your object format is a custom one. If the format is under your control, you could consider using the ELF format with your bytecode as a new machine architecture, a la x86, SPARC, ARM, etc. The GNU binutils sources are sufficiently malleable to allow you to incorporate your "architecture".

Common way to get BIOS information via C

After reading some stuff it seems I can map the SMBIOS memory and parse it.
I have no idea on how to go about this.
I can't use any managed code as I would like this to be compilable under any OS.
Does anyone have any code examples how to go about this?
On most systems, it is not mapped into user-mode accessible memory, so you need to call some system API.
On Windows, you can call GetSystemFirmwareTable.
For Linux I guess you should have a look at the dmidecode source (GPL) for concrete code...
Using and parsing dmidecode output may be all you need...
I wrote a reusable class to read all the SMBIOS stuff.
It is very clean code with a proper error handling and easy to extend.
You can derive a class from this class that uses the parsed data to display it or do whatever you want with it.
You find also a link to the actual SMBios documentation in the code's comments.
You can download it from my homepage:
ftp://ftp.netcult.ch/mirror/elmue/SMBiosClass.zip
Elmue

Resources