Re: Correct objcopy Usage (was Re: C23 thoughts and opinions)

Liste des GroupesRevenir à cl c 
Sujet : Re: Correct objcopy Usage (was Re: C23 thoughts and opinions)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.c
Date : 04. Jun 2024, 05:33:36
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v3m5f0$97jb$4@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
User-Agent : Pan/0.158 (Avdiivka; )
On Sat, 1 Jun 2024 11:24:20 +0100, bart wrote:

Here's my transcript:

Here’s how to do it. To create the blob object from the blob file
(replace «blobfile» with the file name as appropriate):

    BLOBFILE=«blobfile»
    objcopy -I binary -O elf64-x86-64 \
        --redefine-sym _binary____$(basename $BLOBFILE)_start=blob_start \
        --redefine-sym _binary____$(basename $BLOBFILE)_end=blob_end \
        --redefine-sym _binary____$(basename $BLOBFILE)_size=blob_size \
        $BLOBFILE blob.o

Then compile and link blob.o against this example mainline:

    #include <stdio.h>
    #include <stdint.h>

    extern uint8_t blob_start;
    extern uint8_t blob_end;
    /* extern uint8_t blob_size; */

    int main()
      {
         fprintf(stdout, "start = %p\n", &blob_start);
         fprintf(stdout, "end = %p\n", &blob_end);
         fprintf(stdout, "size = %d\n", &blob_end - &blob_start);
         return 0;
      } /*main*/

(There’s a warning which I’m ignoring for now.) Then run and see if
the results are what you expect.

Note I haven’t figured out how to use the “blob_size” symbol. It
appears, seemingly correctly, as an absolute symbol in a dump by “nm”,
but any attempt to reference it from the C code produces relocation
errors.

Date Sujet#  Auteur
31 May 24 o Re: C23 thoughts and opinions73bart

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal