Sujet : Re: C23 thoughts and opinions
De : already5chosen (at) *nospam* yahoo.com (Michael S)
Groupes : comp.lang.cDate : 31. May 2024, 15:34:37
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240531173437.00003bee@yahoo.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
User-Agent : Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)
On Fri, 31 May 2024 15:04:46 +0100
bart <
bc@freeuk.com> wrote:
On 31/05/2024 14:48, Michael S wrote:
On Fri, 31 May 2024 16:28:11 +0300
Michael S <already5chosen@yahoo.com> wrote:
On Fri, 31 May 2024 16:19:37 +0300
Michael S <already5chosen@yahoo.com> wrote:
>
No, it does not work like that.
First, copy *exactly* what I said in my previous post.
Only after you reproduced, start to be smart.
_binary_hello_c_size is a link simbol rather than variable.
>
Declaration:
extern char _binary_hello_c_size[];
>
Usage:
printf("%zd\n", (size_t)_binary_hello_c_size);
>
Thinking about it, I could be wrong.
I should test more, with less small program.
I tested with bigger program, and it's still works.
So, what written above is correct.
Can you show the full program and the full process?
test_objcopy.c:
#include <stdio.h>
int data1[42] = { 1,2,3 ,4,5};
extern unsigned char _binary_test_bi_start[];
extern unsigned char _binary_test_bi_end[];
extern unsigned char _binary_test_bi_size[];
extern unsigned char _binary_bin_to_list_c_start[];
extern unsigned char _binary_bin_to_list_c_end[];
extern unsigned char _binary_bin_to_list_c_size[];
int main()
{
printf("%-40s %p %zd\n", "_binary_test_bi_start",
_binary_test_bi_start, (size_t)_binary_test_bi_start);
printf("%-40s %p %zd\n", "_binary_test_bi_end",
_binary_test_bi_end, (size_t)_binary_test_bi_end);
printf("%-40s %p %zd\n", "_binary_test_bi_size",
_binary_test_bi_size, (size_t)_binary_test_bi_size);
printf("%-40s %p %zd\n", "_binary_bin_to_list_c_start",
_binary_bin_to_list_c_start, (size_t)_binary_bin_to_list_c_start);
printf("%-40s %p %zd\n", "_binary_bin_to_list_c_end",
_binary_bin_to_list_c_end, (size_t)_binary_bin_to_list_c_end);
printf("%-40s %p %zd\n", "_binary_bin_to_list_c_size",
_binary_bin_to_list_c_size, (size_t)_binary_bin_to_list_c_size);
return 0;
}
Test files: test.bi and bin_to_list_c.
Conversion to ojects:
objcopy -I binary -O elf64-x86-64 test.bi test_bi.o
objcopy -I binary -O elf64-x86-64 bin_to_list.c test_c.o
Compilation:
gcc -s -Wall -Oz test_objcopy.c test_bi.o test_c.o
I compiled with additional option -Xlinker -Map=test_objcopy.map
in order to make myself sure tha *_size are indeed pure symbols that
have no memory allocated underneaths.