Skip to content
Advertisement

Linux readelf shows object sizes with different numeral system (Hex and Dec)

I’m investigating some objects inside ELF file and using readelf for that purpose.

This sample of readelf shows the size (bytes) of the objects on column 3,

On large objects, readelf prints in Hex instead of dec,

This breaks my size sorting attempts. (sorting ignores hex value)

JavaScript

I tried translating all hex to dec like this:

JavaScript

and got

JavaScript

The size column (3) is translated to dec, which is good,

But also column 2 is translated to dec which is bad..

I found this:

JavaScript

from

find-and-replace-confined-to-a-specific-column-one-liner

But I can’t seem to combine those 2 commands.

How can I translate only column 3 to dec?

Thanks

Advertisement

Answer

Only convert sequences that start with 0x:

JavaScript

Only convert fields that start with 0x:

JavaScript

Only convert the third field if it’s starts with 0x:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement