Operating System - HP-UX
1829566 Members
1263 Online
109992 Solutions
New Discussion

find compilation flags from a shared library

 
SOLVED
Go to solution
Manas Ranjan Sahu
New Member

find compilation flags from a shared library

Hi,

There are many situations where we are required to find out the compilation flags used while creating a library. I tried using elfdump, but it does not show information regarding this.

Anyone has any idea how to find this out?

Also, how to find out if a shared library contains debugging information or not. Any specific command or trick? One trick I used is to open it in gdb and use the list command and if this shows the file name, the library contains debugging information. Any other trick?
6 REPLIES 6
Dennis Handly
Acclaimed Contributor
Solution

Re: find compilation flags from a shared library

>I tried using elfdump, but it does not show information regarding this.

Did you use "elfdump -dc"?

>how to find out if a shared library contains debugging information or not.

elfdump -dc or footprints(1) will show it.

Or you can use "elfdump -S -h" and look for the real debug sections:
.debug_info .debug_macinfo .objdebug_*
Manas Ranjan Sahu
New Member

Re: find compilation flags from a shared library

Thank you Dennis.

elfdump output is:

elfdump -S -h libmpr_events.so | grep "debug"
39 PBIT 0000000000000000 000000000095aa68 0005a0a1 .objdebug_type
40 PBIT 0000000000000000 00000000009b4b09 0010024b .objdebug_file
41 PBIT 0000000000000000 0000000000ab4d54 00007f71 .objdebug_const
43 PBIT 0000000000000000 0000000000af5cd0 004fe49f .debug_line
44 PBIT 0000000000000000 0000000000ff416f 00130dd5 .debug_actual
45 PBIT 0000000000000000 0000000001124f44 00033630 .debug_procs_abbrev
46 PBIT 0000000000000000 0000000001158574 001a000b .debug_procs_info

and footprints gives:

footprints libmpr_dd.so | less

...
version [A.06.25.01/ANSI C++ 1]
architecture [ipf64 1]
-O [01 1]
PBO [off 1]
-g [1 1]
debugopt [+O1 1]

+Ointeger_overflow [moderate 1]
+Olit [all 1]
-ansi_for_scope [on 1]
-fpeval [float 1]
-inline [1 1]
-koenig_lookup [on 1]
-link_type [dynamic 1]
...

Although it seems it is compiled with debug information (-g), still when debugging, it is unable to load any information. See one of the core stack:

(gdb) where
#0 0xc00000000b890cb0:0 in adj::pe_base::EventBaseData::serialize (
No.Identifier_47=0x9fffffff7b0fff40, this=0x9fffffffa9d26aa8,
i_pBuffer=0x9fffffffa77000fb "410118298330", i_bufferLength=1365)
at /jphome/jp/ccjp/mb_ccjp/bb/gapebase/v75_0_S2P1D/entities/src/EventBase.cpp:163
#1 0xc00000000b895f60:0 in adj::pe_base::EventBase::serialize (
No.Identifier_51=0x9fffffff7b0fff40, this=0x9fffffffa9d26aa0,
o_pBuffer=0x9fffffffa77000fb "410118298330", i_bufferLength=1365)
at /jphome/jp/ccjp/mb_ccjp/bb/gapebase/v75_0_S2P1D/entities/src/EventBase.cpp:121
#2 0xc00000001766d500:0 in mapper::eventTypes::GPRSV1::serialize(char*,unsigned long)+0x70 ()
from /prdtc5/inf/aimsys/prdtc5/abp_home/custom/spbin/lib/libmpr_events.so
#3 0xc00000001112d960:0 in adj::rr_utils::RRSession::addEvent (
this=0x60000000cce35880, i_pEvent=0x9fffffffa9d26aa0)
at /jphome/jp/ccjp/mb_ccjp/bb/gesrrutils/v75_0_S2P1D/session/src/RRSession.cpp:376

For frame #2, which is present in the library I am interested in, I am not getting much information like I get for other frames. I tried using sharedlib and share command inside gdb to load symbols from libmpr_events.so, but to no avail.

Any pointers?

Dennis Handly
Acclaimed Contributor

Re: find compilation flags from a shared library

>.debug_line .debug_actual .debug_procs_abbrev .debug_procs_info

These are also present in the Minimal Line Table.
The objdebug_* sections indicate the debug info is left in the object files, +objdebug, the default.

>-g [1 1]

One file with -g.

>For frame #2, which is present in the library I am interested in, I am not getting much info

Did you get a message saying it couldn't find the object file?
Manas Ranjan Sahu
New Member

Re: find compilation flags from a shared library

Thank you Dennis. It seems the debug information are indeed inside the object files. When I do up command:

(gdb) up
warning:
ERROR: Use the "objectdir" command to specify the search
path for objectfile events1.o.
If NOT specified will behave as a non -g compiled binary.

I am trying to get all the object files to this machine and try debugging again.

BTW, when I looked at the elfdump as well as footprints output, it seems that we are not getting any information about -DXXX flags. Is there a way to find them as well?

Dennis Handly
Acclaimed Contributor

Re: find compilation flags from a shared library

>it seems that we are not getting any information about -DXXX flags. Is there a way to find them as well?

No, these are deliberately removed and as being not all that useful in triaging user problems by the Response Center and taking up too much space.
Dennis Handly
Acclaimed Contributor

Re: find compilation flags from a shared library

>I am trying to get all the object files to this machine and try debugging again.

If it is too inconvenient to do that, you can compile and/or link with +noobjdebug.
This will bloat your load modules.