Liste des Groupes | Revenir à cl c |
bart <bc@freeuk.com> writes:Did you see the output from my version of Michael S's program? The size is just an address. If I do what you do:On 31/05/2024 15:34, Michael S wrote:On Fri, 31 May 2024 15:04:46 +0100
bart <bc@freeuk.com> wrote:Instead of one compiler, here I used two compilers, a tool 'objcopy'$ objcopy -I binary -O elf64-x86-64 main.cpp /tmp/test.o
(which bizarrely needs to generate ELF format files) and lots of extra
ugly code. I also need to disregard whatever the hell _binary_..._size does.
$ objdump -x /tmp/test.o
/tmp/test.o: file format elf64-little
/tmp/test.o
architecture: UNKNOWN!, flags 0x00000010:
HAS_SYMS
start address 0x0000000000000000
Sections:
Idx Name Size VMA LMA File off Algn
0 .data 000030e2 0000000000000000 0000000000000000 00000040 2**0
CONTENTS, ALLOC, LOAD, DATA
SYMBOL TABLE:
0000000000000000 l d .data 0000000000000000 .data
0000000000000000 g .data 0000000000000000 _binary_main_cpp_start
00000000000030e2 g .data 0000000000000000 _binary_main_cpp_end
00000000000030e2 g *ABS* 0000000000000000 _binary_main_cpp_size
$ ls -l main.cpp
-rw-rw-r--. 1 scott scott 12514 May 9 2022 main.cpp
$ printf '%u\n' $(( 0x30e2 ))
12514
The value of the symbol _binary_main_cpp_size is the
number of bytes in the file.
(in other words,
_binary_main_cpp_size = _binary_main_cpp_end - _binary_main_cpp_start
)
In C code:
extern uint8_t _binary_main_cpp_size;
const size_t embed_size = &_binary_main_cpp_size;
Les messages affichés proviennent d'usenet.