autoconf
[Top][All Lists]
Advanced

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

"Packing" binary data into object files using autotools


From: Thomas Nyberg
Subject: "Packing" binary data into object files using autotools
Date: Mon, 14 Aug 2017 12:19:06 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

Hello,

I have a Makefile which I'm trying to convert to an autotools setup.
It's complicated by the fact that some code is not compiled until
runtime. I'll try to be as detailed as possible. In my hand-written
Makefile I have the following setup. I have a rule which tars up some
files and puts it in `code.tar`. Next I inject that code into an object
file using some basic gnu assembler instructions. That object file is
linked elsewhere into the final library. To be more specific, I have the
following situation:

    # Rule injecting a tar archive into object code.
    -------------------------------------------------------------------
    code_archive_tar:
        tar c --exclude='*.o' code/ > code.tar
        as -o code_archive.o code_archive.S
        rm -f code.tar
    -------------------------------------------------------------------

    # This is the actual code_archive.S file referenced above:
    -------------------------------------------------------------------
        .section .rodata
        .global code_archive_tar
        .type   code_archive_tar, @object
        .align  4
    code_archive_tar:
        .incbin "code.tar"
    code_archive_tar_end:
        .global code_archive_tar_size
        .type   code_archive_tar_size, @object
        .align  4
    code_archive_tar_size:
        .int    code_archive_tar_end - code_archive_tar
    -------------------------------------------------------------------

    # The actual data is accessed in another (C++) source file as
    # follows:
    -------------------------------------------------------------------
    extern char code_archive_tar[];
    extern unsigned code_archive_tar_size;
    -------------------------------------------------------------------

The important parts of my current Makefile.am specified its required
sources as follows:

    # Makefile.am
    -------------------------------------------------------------------
    [...]

    library_la_SOURCES = \
        ... [A bunch of files...]

    libmerriamengine_la_LDFLAGS = \
        ... [A bunch of libraries...]

    CXXFLAGS = \
        ... [A bunch of compiler flags]

    [...]
    -------------------------------------------------------------------

It's hard for me to fit my own setup into this since autotools is
finding all the different files and linking them pretty automagically.
Basically what I need is (1) to signal some way for the tar procedure to
occur before the rest of the linking takes place and (2) to actually
signal to the linking phase that the object file that has been created
needs also to be added to the link itself.

Hopefully this isn't too confusing. I was reading about BUILT_SOURCES,
but I'm not totally sure that that is what I require. I also have added
in explicit Makefile rules into Makefile.am (e.g. the rule to tar up the
folder structure), but I'm having trouble getting (1) and (2) to work in
the last paragraph.

Any help is appreciated! Definitely yell at me if you need more info or
something I'm saying doesn't make sense! Thanks a lot!

Cheers,
Thomas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]