Re: Determining size of embedded blobs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jean Hoderd wrote:

> Normally I know the size of the blob I just linked in.
> But suppose I didn't.  Is there a way I can determine
> it from within the C program?  I know that by running
> "objdump -x blob.o" I can see the symbol table on the
> obj file, and that the symbols _binary_blob_png_end and
> _binary_blob_png_size are also defined:
> 
> SYMBOL TABLE:
> 0000000000000000 l    d  .data  0000000000000000 .data
> 0000000000000400 g       .data  0000000000000000 _binary_blob_png_end
> 0000000000000000 g       .data  0000000000000000 _binary_blob_png_start
> 0000000000000400 g       *ABS*  0000000000000000 _binary_blob_png_size
> 
> I assumed that _binary_blob_png_end was a pointer to the
> end of the blob, but it doesn't seem so.  Also, I always
> get a segfault if I assume that _binary_blob_png_size is
> an integer value.

_binary_blob_png_end is a pointer to the byte just past the blob;
subtracting _start from _end gets you the size.

_binary_blob_png_size is a weird symbol; symbols can only be addresses,
not data, so you can't reference the _size symbol directly. You must
take its address, then cast from a pointer to a size_t. However, I would
recommend using the _end - _start method instead, because the _size
symbol will get modified if it is located in a shared library and will
become useless.

-- 
Kevin P. Fleming
Director of Software Technologies
Digium, Inc. - "The Genuine Asterisk Experience" (TM)

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux