Questions tagged [objcopy]

142 questions
5
votes
3 answers

huge binary files with objcopy

Im having problems when I define global variables in a basic C program for an ARM9 processor. I'm using EABI GNU compiler and the binary generated from a 12KB elf is 4GB! I assume the issue is with my scatter file but Im having trouble getting my…
Damn
  • 83
  • 1
  • 1
  • 6
5
votes
1 answer

Make Executable Binary File From Elf Using GNU objcopy

I'd like to copy an executable ELF file via: $ objcopy -O binary myfile.elf myfile.bin Unfortunately: $ chmod +x myfile.bin $ ./myfile.bin results in: cannot execute binary file Is there any way to retain the files executability?
user2985888
  • 75
  • 1
  • 1
  • 6
5
votes
2 answers

Edit variable values in ELF file?

I need to change a couple of variables in a compiled ELF file. Trying to explain this clearly I'll use a simple C struct as an example. The single source file is compiled and linked (@ 0x1000) into MyFile.elf from MyFile.c: typedef struct { …
barnie82
  • 131
  • 1
  • 9
4
votes
0 answers

Manually patching an elf binary - adjusting symbols / versions names

This post is asking about modifying / patching or even hexediting - due to lack of better methods (see Notes) an elf binary to adjust functions / symbols / versions they point to - and keeping ld.so happy + asking for some Tools to ease this…
cg79
  • 63
  • 5
4
votes
1 answer

Custom command to generate object(.o) from binary file using autoconf

We have a project (c++) and it needs to include a binary file into shared library. This is done on windows by referencing the binary file from a resource file. On Linux it can be achieved by using objcopy as shown here The question is how can this…
Satpal
  • 309
  • 2
  • 8
4
votes
0 answers

Differences between GCC/Clang when linking

Because of vastly better C++ compile times I've recently added the option to compile a project for an ARM Cortex-M4 microcontroller with Clang instead of the arm-none-eabi-gcc toolchain. The whole process ran quite smoothly and I quickly had working…
Vinci
  • 1,382
  • 10
  • 12
4
votes
1 answer

GNU Assembler .long Declaration Zeroed Out

When assembling code with GNU Binutils declarations such as: .long MY_Label .long MY_Second_label Assemble without errors but consistently map to zeroed out 32-bit strings when doing a hex dump even when opcodes and other information separate them…
user2108
  • 43
  • 6
4
votes
1 answer

Linker Script Does Not Skip Bytes As Expected

So, I have this assembly file, which I assemble with GNU as and link with GNU ld using a linker script. Linker script (boot.ld): INPUT(boot.o) OUTPUT(boot.out) ENTRY(boot_start) SECTIONS { . = 0x7c00; .text : { *(.text) } …
cadaniluk
  • 15,027
  • 2
  • 39
  • 67
4
votes
2 answers

Objcopy, how it makes binary output?

As I'm new to binutils, gcc ant others, I have some general questions, anwsers on which I havn't found in manuals. I'm using C and assembly(nasm syntax) and I need raw binary files on output. First of all, I compile my code to objec file with…
hrust
  • 734
  • 1
  • 11
  • 34
3
votes
1 answer

How to obtain the BFD architecture specification for the current platform?

I've embedded a text file in a C program using the following method: http://www.linuxjournal.com/content/embedding-file-executable-aka-hello-world-version-5967 a.out:prog.c file.text objcopy --input binary --output elf64-x86-64…
Pierre
  • 34,472
  • 31
  • 113
  • 192
3
votes
1 answer

Why does running objcopy --strip-all in a rust program halves their size?

When I execute objcopy --strip-all in any rust program it halves their size. For example if I compile an normal hello world application with cargo build --release it ends with an 3 mb executable (in linux). Then when i run objcopy --strip-all on the…
undefined
  • 31
  • 1
  • 2
3
votes
0 answers

What is the difference between strip --remove-section vs objcopy --remove-section

Both strip and objcopy binary utilities support [--remove-section=sectionname] option. Is there a difference between the two options ? Are there cases when one should be preferred over the other?
Cherry Vanc
  • 781
  • 1
  • 4
  • 19
3
votes
1 answer

Remove section created with __attribute__((section))

I have a number of functions and corresponding unit tests. I would like to embed the tests into the codebase itself. I came up with the following solution: void a() { // this code should be tested } __attribute__((section(".tests"))) void…
asynts
  • 2,213
  • 2
  • 21
  • 35
3
votes
2 answers

Unforeseen consequences of objcopy on static libraries

Background I have a set of three nearly identical static c libraries (compiled with -fPIC), for which I am not able to have them recompiled. All libraries export the same symbols, so the only way I can bundle them together is to to modify the…
Cloud
  • 18,753
  • 15
  • 79
  • 153
3
votes
1 answer

How do I convert a binary firmware dump to an .elf for assembly language debugging?

I have a binary firmware image for ARM Cortex M that I know should be loaded at 0x20000000. I would like to convert it to a format that I can use for assembly level debugging with gdb, which I assume means converting to an .elf. But I have not been…
joeforker
  • 40,459
  • 37
  • 151
  • 246
1
2
3
9 10