Custom rule to add ELF section to binary

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Custom rule to add ELF section to binary

Andy Falanga (afalanga)
I'm investigating a means of adding a section to the ELF binary being
built.  The Shared Object file is a python module and I'm using this to
do so:

I'm looking to embed certain, non-loadable, text information into the
ELF binary; e.g. a legal notice.  I'm using objcopy to do this in a
sandbox which *does not use* autotools.  For example,

g++ -o myprog main.cxx
echo "Some important legal notice" > legal_temp.txt
objcopy --add-section .legalnotice=legal_temp.txt
--set-section-flags=noload,readonly myprog myprog.copy
mv myprog.copy myprog

I know how to place custom rules into  I'm doing so for
some BUILT_SOURCES.  What I'm wondering now is, how would I add a rule
for the output?  Could I add a rule for a single component object file,
which is later linked into the library?  Which would be simplest?  How
do figure out what the name of the target is that the autotools system
makes?  They seem quite long and I don't want to hard-code a name that
will not exist on all systems.  Is there some type of "Post Build"
primary that I should use instead of trying a custom rule?