0

I have been using the Quagga dynamic routing daemon on a CentOS 6 VM. I'd like to use a feature that is only accessible if the RPM was built with the --multipath=X flag. The RPM I'm using was already built and obtained from the CentOS repository.

Is there a way to find out if the RPM was built with this flag or do I have to build from source and supply that flag myself?

I downloaded the RPM source package and noticed that in the supplied spec file the multipath parameter is set to 64. So I could just build it myself if I need to.

AdminBee
  • 21,637
  • 21
  • 47
  • 71
dutsnekcirf
  • 161
  • 1
  • 5
  • 1
    Does this answer your question? [Can we get compiler information from an elf binary?](https://unix.stackexchange.com/questions/719/can-we-get-compiler-information-from-an-elf-binary) – user1794469 Aug 12 '20 at 00:54

2 Answers2

1

In general, the specific compiler flags used to build a userspace binary are not preserved within the binary. No reason for them to be.

You can typically figure out which compiler and compiler version was used to build the binary by examining it's crt0 but even that information can be obfuscated by using a custom crt0.

Assuming it is not a static binary, you may be able to infer particular compile/build time options by examining which shared objects (".so") the binary is using and what functions from each shared object the binary is using.

If you have the source code, you can examine the disassembly listing and determine with reasonable accuracy whether a particular option flag was used when the binary was built.

fpmurphy
  • 4,556
  • 3
  • 23
  • 26
  • Could you describe how I could determine which shared objects the binary is using? Is that the readelf -d command? It displays a lot of shared libraries but that doesn't really make it very clear to me whether that flag was used. How do I examine a binary's crt0? – dutsnekcirf Aug 12 '20 at 14:15
  • @dutsnekcirf. Easiest way is to use a tool such as IDA Pro or Binary Ninja. – fpmurphy Aug 12 '20 at 14:48
1

As @fpmurphy said, the compiler flags are not usually preserved within the binary. And the build-time options like --multipath=X are most likely options for the ./configure script, so they might do something like controlling the generation of a config.h file, which will then participate in the build process without necessarily affecting compiler flags at all.

But when a program has a lot of such options, there is sometimes (not always) a way to find out the state of the relevant build-time options. If this information is available, it can often displayed via programname --version or similar option that displays version information.

I don't know Quagga at all, but the documentation section describing its Terminal Mode Commands has one promising-looking command:

Command: show version

Show the current version of Quagga and its build host information.

The "build host information" just might include information about the build-time options. Or it might not. But if I had no easier sources of information, that would be one of the first places I'd look.

If the software is packaged, and you can find the corresponding source package, the general idea is that the source package includes all the build-time configuration required to produce a binary that is at least 100% functionally equivalent to the one distributed in the corresponding binary package(s) of the same distribution. If the distribution is using the new-ish "reproducible builds" techniques, the resulting binary might even be bit-for-bit identical.

So, the source package (and in the case of a RPM, its .spec file in particular) is a good source of information on build-time options used in the corresponding binary package.

Assuming that the source RPM whose .spec file you checked also came from CentOS's repository and had the same version as your binary, the standard assumption would be that yes, --multipath=64 was used in producing the binary RPM. If you find that's not actually true, that would be a very good reason to make a bug report or otherwise contact the distributor and report the discrepancy.

telcoM
  • 87,318
  • 3
  • 112
  • 232
  • 1
    The OP stated in their Q that they downloaded the source RPM, examined the `.spec` file, and determined `multipath` was set to 64. – fpmurphy Aug 12 '20 at 14:39