tags:

views:

82

answers:

3

On a production Linux box without development tools installed (e.g. no headers, no gcc) how do you figure out if it will be able to execute stuff:

  • compiled under gcc4.1.2 as opposed to gcc3.3.3 (there was a change in ELF between version 3 and 4 I think)
  • compiled for 64 bit as opposed to 32 bit executables

We have some legacy libraries so we still use gcc3.3.3 but are moving to gcc4.1.2 and colleague was trying to figure out how to detect on new remote box if we can execute stuff compiled with gcc4.

Can I check for specific version of libraries or ld-linux.so or something like that instead of actually compiling test app with gcc4 and then try to run it on the new box?

+2  A: 

Generated code should run fine. You can try to run ldd, since it uses the machine dynamic linker, you can see if any libraries is missing.

shodanex
I'm trying to figure out if the box is setup to execute stuff compiled with gcc4. I assume you suggest to compile app then copy it to the remote box and then run ldd on it. This is what I would normally do, but I'm trying to figure out if there's any other simple way by just looking at libraries or running a command or something like that. But thanks for your suggestion anyway.
stefanB
+1  A: 

I think the problems you are referring to are with GNU ld not gcc. There was a new hash algorithm added for symbol lookup. You should compile everything with -Wl,--hash-style=both or -Wl,--hash-style=sysv (the default) in gcc4 then you won't have any problems. From memory Redhat was the only distro retarded enough to enable the gnu hash style by default.

If indeed that is your problem then you can tell by doing:

objdump -t foo | grep " .hash"

Which will be empty unless a sysv hash is present.

Dean Povey
A: 

Seems like there isn't a simple way of looking at version of some of the libraries to determine if gcc4 binaries will run without any problems.

I personally have no issues with executing any of the checks mentioned in the other responses, but I was looking for a static way of determining this, so that someone else in my team can check the linux box without giving me 30 minutes presentation about how linux should work ...

stefanB