Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8599913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:30:03+00:00 2026-06-12T01:30:03+00:00

We have a large set of C++ projects (GCC, Linux, mostly static libraries) with

  • 0

We have a large set of C++ projects (GCC, Linux, mostly static libraries) with many dependencies between them. Then we compile an executable using these libraries and deploy the binary on the front-end. It would be extremely useful to be able to identify that binary. Ideally what we would like to have is a small script that would retrieve the following information directly from the binary:

$ident binary
$binary : Product=PRODUCT_NAME;Version=0.0.1;Build=xxx;User=xxx...
$  dependency: Product=PRODUCT_NAME1;Version=0.1.1;Build=xxx;User=xxx...
$  dependency: Product=PRODUCT_NAME2;Version=1.0.1;Build=xxx;User=xxx...

So it should display all the information for the binary itself and for all of its dependencies.

Currently our approach is:

  1. During compilation for each product we generate Manifest.h and Manifest.cpp and then inject Manifest.o into binary

  2. ident script parses target binary, finds generated stuff there and prints this information

However this approach is not always reliable for different versions of gcc..
I would like to ask SO community – is there better approach to solve this problem?

Thanks for any advice

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:30:05+00:00Added an answer on June 12, 2026 at 1:30 am

    One of the catches with storing data in source code (your Manifest.h and .cpp) is the size limit for literal data, which is dependent on the compiler.

    My suggestion is to use ld. It allows you to store arbitrary binary data in your ELF file (so does objcopy). If you prefer to write your own solution, have a look at libbfd.

    Let us say we have a hello.cpp containing the usual C++ “Hello world” example. Now we have the following make file (GNUmakefile):

    hello: hello.o hello.om
        $(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@
    
    %.om: %.manifest
        ld -b binary -o $@ $<
    
    %.manifest:
        echo "$@" > $@
    

    What I’m doing here is to separate out the linking stage, because I want the manifest (after conversion to ELF object format) linked into the binary as well. Since I am using suffix rules this is one way to go, others are certainly possible, including a better naming scheme for the manifests where they also end up as .o files and GNU make can figure out how to create those. Here I’m being explicit about the recipe. So we have .om files, which are the manifests (arbitrary binary data), created from .manifest files. The recipe states to convert the binary input into an ELF object. The recipe for creating the .manifest itself simply pipes a string into the file.

    Obviously the tricky part in your case isn’t storing the manifest data, but rather generating it. And frankly I know too little about your build system to even attempt to suggest a recipe for the .manifest generation.

    Whatever you throw into your .manifest file should probably be some structured text that can be interpreted by the script you mention or that can even be output by the binary itself if you implement a command line switch (and disregard .so files and .so files hacked into behaving like ordinary executables when run from the shell).

    The above make file doesn’t take into account the dependencies – or rather it doesn’t help you create the dependency list in any way. You can probably coerce GNU make into helping you with that if you express your dependencies clearly for each goal (i.e. the static libraries etc). But it may not be worth it to take that route …

    Also look at:

    • C/C++ with GCC: Statically add resource files to executable/library and
    • Is there a Linux equivalent of Windows' "resource files"?

    If you want particular names for the symbols generated from the data (in your case the manifest), you need to use a slightly different route and use the method described by John Ripley here.

    How to access the symbols? Easy. Declare them as external (C linkage!) data and then use them:

    #include <cstdio>
    
    extern "C" char _binary_hello_manifest_start;
    extern "C" char _binary_hello_manifest_end;
    
    int main(int argc, char** argv)
    {
            const ptrdiff_t len = &_binary_hello_manifest_end - &_binary_hello_manifest_start;
            printf("Hello world: %*s\n", (int)len, &_binary_hello_manifest_start);
    }
    

    The symbols are the exact characters/bytes. You could also declare them as char[], but it would result in problems down the road. E.g. for the printf call.

    The reason I am calculating the size myself is because a.) I don’t know whether the buffer is guaranteed to be zero-terminated and b.) I didn’t find any documentation on interfacing with the *_size variable.

    Side-note: the * in the format string tells printf that it should read the length of the string from the argument and then pick the next argument as the string to print out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have large set of flow charts and workflow diagrams. I want to draw
I have a large set of data that is generated from a web service
I have a large set of documents in a CouchDB database that were just
I have a large set of numbers, probably in the multiple gigabytes range. First
I have a large set of words (about 10,000) and I need to find
I have a large set of values V, some of which are likely to
I have a large set of lines, which I render from a vertex buffer
I have a large set of strings. I want to divide the strings into
I have a large set of data which I access via a generator/iterator. While
Basically I have a large set of data in excel, and I was wondering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.