3

I am using objcopy to remove some necessary scripting to embed a resource file (zip file) in flash memory (ARM embedded thingy).

I am using objcopy like this:

arm-none-eabi-objcopy.exe -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata input.zip input.zip.o
arm-none-eabi-nm.exe -S -t d input.zip.o
00006301 R _binary_input_zip_end
00006301 A _binary_input_zip_size
00000000 R _binary_input_zip_start

What I need to know is what is the width of the _end and _size symbols. I can only guess that the _start is an address which can be accessed like a byte array: extern uint8_t _binary_input_zip_start[];. And I am assuming that the _end and _size are of 'native' int-size, and I suppose I can safely assume I can interpret these as uint32_t.

However I can't be certain. I can't find anything "size" related in the docs of objcopy: https://sourceware.org/binutils/docs/binutils/objcopy.html

Daan Timmer
  • 14,771
  • 6
  • 34
  • 66
  • 3
    I would use some scripting around `hexdump` to create a big C `data.c` file containing `const char zipcontent[] =`...`;` then link `data.o`. No need to use `objcopy` tricks. – Basile Starynkevitch Dec 01 '14 at 08:26
  • @BasileStarynkevitch yeah, we used to use that, however that generated .c file needed to be added to SVN because of a buildserver which else wouldnt build first run. (It first looked for the files needed for building an index, then ran "pre-build" commands (creating said .c file) and then erroring out because said file did not exist before pre-build). But having that generated in SVN was quite annoying as well. – Daan Timmer Dec 01 '14 at 10:40
  • I'm not sure but you can use `objdump` to read the values. I lost something of important in your question? – Michele d'Amico Dec 02 '14 at 13:15
  • Ney, objdump doesn't specify the type of them variables either. All I want to know is if they should be read as uint8_t[], uint16_t[], uint32_t[], void[]. Software works just fine by subtracting end with start to get the amount of bytes and reading it on a per-byte (uint8_t) basis. I just would like to know the underlying type for specifying the correct 'extern' type. – Daan Timmer Dec 05 '14 at 10:28

1 Answers1

0

I'm not %100 sure if this will work, but try adding the option --sort-size to arm-none-eabi-nm. This is supposed to sort the symbols by size, by comparing them to the next symbol above. In combination with the -S option, it should print a size. Hopefully, this will help you deduce their width.

What ARM micro are you using? 32-bits is a good guess, but there are exceptions. If you happen to be using a Texas Instruments part, I can help a lot more. I don't have an ARM project handy that I can test this on, but it's worth a shot. If that doesn't work, I'll keep digging.

Source: My knowledge, and double-checking via http://manned.org/arm-none-eabi-nm

Aurelius
  • 414
  • 4
  • 16