Questions tagged [objcopy]

142 questions
1
vote
1 answer

Including a separate binary into an ELF executable

I am developing an operating system. I would like to include a small asm program into my main kernel elf that can serve as the first process to load. I am having trouble getting this to work. The program is initcode.s. I using the following Makefile…
ErwinM
  • 5,051
  • 2
  • 23
  • 35
1
vote
0 answers

Weaving a binary file from an object file using LD and objcopy

I am trying to build a custom binary file which data mostly comes from a .o file, compiled from a big C file which looks like the following: int a[] = { ... }; int b[] = { ... }; int c[] = { ... }; This C file basically contains a big set of data…
Gnurou
  • 7,923
  • 3
  • 22
  • 32
1
vote
1 answer

Is it possible to run an executable built for one operating system on another?

I know about Wine/Darling and other compatibility layers, but I was wondering if it was possible (for example) this way: 1. Build a simple hello_world.c program on OS X. 2. Using objcopy/objconv/some other tool, copy the machine code into a Linux…
Mitsos101
  • 551
  • 3
  • 15
1
vote
1 answer

Prevent g++ adding extra elf sections

When compiling with g++ it creates an extra section for almost each function. This occurs on linux with elf64 executable. By example: text._ZN12MemoryMapper11SetUpMemoryEP11KernelStart How can I tell g++ to emit all code on .text so there is only…
felknight
  • 1,383
  • 1
  • 9
  • 25
1
vote
1 answer

Compile code to raw binary

I'm trying to compile my code into raw binary and as suggested by other SO posts (like this and this) I tried objdump: $ gcc -c foo.c $ objcopy -O binary foo.o foo.bin Then I tried to make sure if this is valid: $ objdump -d foo.o foo.o: file…
Elektito
  • 3,863
  • 8
  • 42
  • 72
1
vote
1 answer

OSX gobjdump corrupts executable

I am trying to create the equivalent of pdb files on windows to have builds with separate debug info files. I installed and tried using gobjdump to remove debug information from a small hello world program (testDebugging). I built the code using…
Guru
  • 13
  • 2
1
vote
2 answers

How can I extract an array from an executable file?

I want to do the inverse of this question. I am embedding a file into an executable as an array, and I would later like to extract the embedded file from the executable. It seems like objcopy might be useful here but I haven't figured out the proper…
bstpierre
  • 30,042
  • 15
  • 70
  • 103
1
vote
0 answers

GCC create flat binary with correctly linked data section

I try to create a flat binary file with gcc using objcopy. My C code looks like: char* str = "Hello world!"; printString(str,12); When I create my binary with C:\MinGW\bin\gcc -c cfile.c -o cfile.o C:\MinGW\bin\gcc -nodefaultlibs -nostdlib -o…
kaetzacoatl
  • 1,419
  • 1
  • 19
  • 27
1
vote
0 answers

Can I use objcopy to convert a library from one ARM architecture to another?

I have to use a library that was precompiled for an ARM Cortex M4 in a project with an ARM Cortex A8. The linker naturally gives me an error: file "..." has a Tag_CPU_arch_profile attribute value of "77" that is different than one previously seen…
TM_
  • 21
  • 8
1
vote
1 answer

How to move gcc debug symbols outside from .so and .a files?

as far as I know, objcopy is able to move debug symbols (compiled with -g flag) outside from an executable binary. I found this question, but there are only generic methods for symbol outsourcing. But what can I do when my executable is using some…
Steve M. Bay
  • 313
  • 1
  • 3
  • 15
1
vote
1 answer

objcopy: fails to copy a particular section (`.rodata' required but not present [...])

I compiled a Hello World C file and need just one section (only the hello world function) of it. The compiled file has the format elf32-i386 and contains 4 sections: .rodata, .text.hello, .comment, .eh_frame. I tried to use objcopy to extract only…
Pawel Os.
  • 611
  • 8
  • 26
1
vote
1 answer

Using clang's objcopy with input file returns: "File format not recognized"

I am using the following command arm-linux-androideabi-objcopy --redefine-syms mysyms obj1.o obj2.o. The binary is from the clang3.3 toolchain, which I built using the Android NDK. The mysyms file contains value pairs in the format of boo boo_1 foo…
Paschalis
  • 11,929
  • 9
  • 52
  • 82
1
vote
1 answer

android NDK: objcopy --rename-sym does not work (need to rename a function in a .so file)

I cannot get objcopy --rename-sym working. In a new Android project, I have created the directory jni and the file stub.c: #include #include "dlog.h" jint JNI_OnLoad(JavaVM* vm, void* reserved) { DLOG("~~~~~~~~~~~~~~~~~~~~~~~ JNI_OnLoad…
18446744073709551615
  • 16,368
  • 4
  • 94
  • 127
1
vote
1 answer

Function pointer to "undefined" functions

So, here is the problem. I have compiled some object files, using gcc -c, and I have cloned them using obj-copy. If the a function of the initial object file was named foo(), then the resulting function names in the cloned objects are: foo1();…
Paschalis
  • 11,929
  • 9
  • 52
  • 82
1
vote
2 answers

Rewrite shared library undef symbol version of compiled object

I am trying to compile and link a program (let's call it myprog) which is linked against a shared library (in this instance libcryto & libssl, but the actual library is not relevant). I am building it on Centos 5.5 but want the same binary to run on…
abligh
  • 24,573
  • 4
  • 47
  • 84