Re: C23 thoughts and opinions

Liste des GroupesRevenir à cl c 
Sujet : Re: C23 thoughts and opinions
De : nospam (at) *nospam* please.ty (jak)
Groupes : comp.lang.c
Date : 01. Jun 2024, 12:59:32
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v3f2f3$2oq04$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.18.2
bart ha scritto:
On 01/06/2024 02:37, jak wrote:
bart ha scritto:
I can see that the first two can be subtracted to give the sizes of the data, which is 70 or 0x46. 0x46 is the last byte of the address of _size, so what's happening there? What's with the crap in bits 16-47?
>
I can extract the size using:
>
    printf("%d\n", (unsigned short)&_binary_hello_c_size);
>
But something is not right. I've also asked what is the point of the -size symbol if you can just do -end - -start, but nobody has explained.
>
     typedef unsigned char uchar;
     extern uchar _binary_hello_c_size[];
     long hello_c_size = _binary_hello_c_size - (uchar *)0;
 What result for the size did you get when you ran this?
 It seems people are just guessing what might be the right code and posting random fragments!
 
I wrote it that way precisely because I believed it was the clearest
way. With the extern you can retrive the relative values ​​that in the
case of _start and _end correspond to the initial and final address of
the object, in fact you can get the length of the object by subtracting
the starting address from the final one:
extern char _binary_hello_c_start[];
extern char _binary_hello_c_end[];
long len = _binary_hello_c_end - _binary_hello_c_start;
Unfortunately, _size is provided in the same way as _start and _end addresses, then, since it is not an address but a length and in C:
Address +/- Value = Address
Address +/- Address = Value
so, to retrive this length that in the program it is seen as an address it is sufficient to subtract the starting address which in the case of a length is zero.
extern char _binary_hello_c_size[];
long len = _binary_hello_c_size - (char *)0;
surely you can also recover the value with a cast:
long len = (long)_binary_hello_c_size;
but the example I sent you had seemed more explanatory while the cast
seems to me a blow of hoe.
Here nobody invents anything. I'm sorry you think this.
/*
  *  example:
  *  file to embed:
  *  --- start file.txt ---
  *  line number  1
  *  line number  2
  *  line number  3
  *  line number  4
  *  line number  5
  *  line number  6
  *  line number  7
  *  line number  8
  *  line number  9
  *  line number 10
  *  line number 11
  *  line number 12
  *  line number 13
  *  line number 14
  *  line number 15
  *  line number 16
  *  line number 17
  *  line number 18
  *  line number 19
  *  line number 20
  *  --- end file.txt ---
  *  objcopy --input-target binary --output-target pe-x86-64 --binary-architecture i386 file.txt file.txt.o
  *  gcc embed.c file.txt.o -o embed
  */
#include <stdio.h>
int main()
{
     typedef unsigned char uchar;
     extern uchar _binary_file_txt_start[];
     extern uchar _binary_file_txt_size[];
     long file_txt_size = _binary_file_txt_size - (uchar *)0;
     for(long i = 0; i < file_txt_size; i++)
         putchar(_binary_file_txt_start[i]);
     return 0;
}
output: show file.txt content

Date Sujet#  Auteur
31 May 24 * Re: C23 thoughts and opinions73bart
31 May 24 +* Re: C23 thoughts and opinions67Michael S
31 May 24 i+* Re: C23 thoughts and opinions65Michael S
31 May 24 ii`* Re: C23 thoughts and opinions64Michael S
31 May 24 ii `* Re: C23 thoughts and opinions63bart
31 May 24 ii  `* Re: C23 thoughts and opinions62Michael S
31 May 24 ii   `* Re: C23 thoughts and opinions61bart
31 May 24 ii    +* Re: C23 thoughts and opinions39jak
31 May 24 ii    i+- Re: C23 thoughts and opinions1bart
6 Jun 24 ii    i`* Re: C23 thoughts and opinions37BGB-Alt
7 Jun 24 ii    i +* Re: C23 thoughts and opinions32Lawrence D'Oliveiro
7 Jun 24 ii    i i+* Re: C23 thoughts and opinions15BGB-Alt
8 Jun 24 ii    i ii`* Re: C23 thoughts and opinions14Lawrence D'Oliveiro
8 Jun 24 ii    i ii +* Re: C23 thoughts and opinions11BGB
8 Jun 24 ii    i ii i+- Re: C23 thoughts and opinions1Lawrence D'Oliveiro
13 Jun 24 ii    i ii i`* Re: C23 thoughts and opinions9Bonita Montero
13 Jun 24 ii    i ii i `* Re: C23 thoughts and opinions8BGB
14 Jun 24 ii    i ii i  `* Re: C23 thoughts and opinions7Bonita Montero
14 Jun 24 ii    i ii i   `* Re: C23 thoughts and opinions6BGB
14 Jun 24 ii    i ii i    +* Re: C23 thoughts and opinions2Bonita Montero
14 Jun 24 ii    i ii i    i`- Re: C23 thoughts and opinions1BGB
15 Jun 24 ii    i ii i    `* Re: C23 thoughts and opinions3Lawrence D'Oliveiro
16 Jun 24 ii    i ii i     `* Re: C23 thoughts and opinions2BGB
16 Jun 24 ii    i ii i      `- Re: C23 thoughts and opinions1Lawrence D'Oliveiro
9 Jun 24 ii    i ii +- Re: C23 thoughts and opinions1Lawrence D'Oliveiro
9 Jun 24 ii    i ii `- Re: C23 thoughts and opinions1Michael S
8 Jun 24 ii    i i`* Re: C23 thoughts and opinions16Malcolm McLean
8 Jun 24 ii    i i +* Re: C23 thoughts and opinions14BGB
9 Jun 24 ii    i i i`* Re: C23 thoughts and opinions13Michael S
9 Jun 24 ii    i i i +* Re: C23 thoughts and opinions11bart
9 Jun 24 ii    i i i i`* Re: C23 thoughts and opinions10Michael S
9 Jun 24 ii    i i i i +- Re: C23 thoughts and opinions1Michael S
9 Jun 24 ii    i i i i +* Re: C23 thoughts and opinions7bart
9 Jun 24 ii    i i i i i`* Re: C23 thoughts and opinions6Michael S
9 Jun 24 ii    i i i i i `* Re: C23 thoughts and opinions5bart
9 Jun 24 ii    i i i i i  `* Re: C23 thoughts and opinions4Michael S
9 Jun 24 ii    i i i i i   `* Re: C23 thoughts and opinions3bart
9 Jun 24 ii    i i i i i    `* Re: C23 thoughts and opinions2Michael S
10 Jun 24 ii    i i i i i     `- Re: C23 thoughts and opinions1bart
11 Jun 24 ii    i i i i `- Re: C23 thoughts and opinions1Lawrence D'Oliveiro
10 Jun 24 ii    i i i `- Re: C23 thoughts and opinions1BGB
9 Jun 24 ii    i i `- Re: C23 thoughts and opinions1Lawrence D'Oliveiro
7 Jun 24 ii    i `* Re: C23 thoughts and opinions4BGB
7 Jun 24 ii    i  `* Re: C23 thoughts and opinions3Lawrence D'Oliveiro
7 Jun 24 ii    i   `* Re: C23 thoughts and opinions2BGB
7 Jun 24 ii    i    `- Re: C23 thoughts and opinions1BGB
31 May 24 ii    +* Re: C23 thoughts and opinions19bart
1 Jun 24 ii    i+* Re: C23 thoughts and opinions4jak
1 Jun 24 ii    ii`* Re: C23 thoughts and opinions3bart
1 Jun 24 ii    ii `* Re: C23 thoughts and opinions2jak
2 Jun 24 ii    ii  `- Re: C23 thoughts and opinions1Tim Rentsch
1 Jun 24 ii    i+* Re: C23 thoughts and opinions10bart
1 Jun 24 ii    ii+* Re: C23 thoughts and opinions5Tim Rentsch
1 Jun 24 ii    iii+- Re: C23 thoughts and opinions1Michael S
2 Jun 24 ii    iii`* Re: C23 thoughts and opinions3Tim Rentsch
6 Jun 24 ii    iii `* objcopy -I binary etc... Was: C23 thoughts and opinions2Michael S
6 Jun 24 ii    iii  `- Re: objcopy -I binary etc... Was: C23 thoughts and opinions1Tim Rentsch
1 Jun 24 ii    ii+- Re: C23 thoughts and opinions1David Brown
1 Jun 24 ii    ii+* Re: C23 thoughts and opinions2bart
4 Jun 24 ii    iii`- Re: C23 thoughts and opinions1Lawrence D'Oliveiro
4 Jun 24 ii    ii`- Re: Correct objcopy Usage (was Re: C23 thoughts and opinions)1Lawrence D'Oliveiro
1 Jun 24 ii    i`* Re: C23 thoughts and opinions4Michael S
2 Jun 24 ii    i +* Re: C23 thoughts and opinions2bart
2 Jun 24 ii    i i`- Re: C23 thoughts and opinions1Michael S
6 Jun 24 ii    i `- Re: C23 thoughts and opinions1Michael S
1 Jun 24 ii    `* Re: C23 thoughts and opinions2Michael S
2 Jun 24 ii     `- Re: C23 thoughts and opinions1Tim Rentsch
31 May 24 i`- Re: C23 thoughts and opinions1bart
31 May 24 +- Re: C23 thoughts and opinions1Kaz Kylheku
31 May 24 +- Re: C23 thoughts and opinions1Malcolm McLean
1 Jun 24 `* Re: C23 thoughts and opinions3Malcolm McLean
1 Jun 24  `* Re: C23 thoughts and opinions2bart
1 Jun 24   `- Re: C23 thoughts and opinions1Malcolm McLean

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal