This is an archive of the discontinued LLVM Phabricator instance.

[LNT] Remove `nm` dependency, used `objdump –t` instead
ClosedPublic

Authored by kpdev42 on Nov 26 2021, 6:59 AM.

Details

Summary

It is necessary to use the correct nm and objdump for some targets (for example ARM thumb).
Wrong nm can provide an information but addresses may be wrong. The correct nm for ARM will report the address 0x1234 for a thumb binary, but system’s nm (x86) will report the address 0x1235.
It is very hard to investigate such issues. We suggest to remove nm dependency at all and use objdump -t instead.
Note objdump allows demangling too. It makes the profile page more human friendly.
Here is the objdump -t output format for reference https://github.com/llvm-mirror/llvm/blob/2c4ca6832fa6b306ee6a7010bfb80a3f2596f824/tools/llvm-objdump/llvm-objdump.cpp#L1850

OS Laboratory. Huawei Russian Research Institute. Saint-Petersburg

Diff Detail

Repository
rLNT LNT

Event Timeline

kpdev42 created this revision.Nov 26 2021, 6:59 AM
kpdev42 requested review of this revision.Nov 26 2021, 6:59 AM

Adding Tamar to get an Arm person to review this.

tnfchris accepted this revision.Nov 29 2021, 12:27 AM

The code itself looks fine to me,

Wrong nm can provide an information but addresses may be wrong. The correct nm for ARM will report the address 0x1234 for a thumb binary, but system’s nm (x86) will report the address 0x1235.

Right since nm only reads the ELF header and doesn't need to understand the object format first, so it's unable to strip the Thumb bit as it has no concept of Thumb.
But objdump does need to understand it, for better or worse..

So by depending on objdump it does mean you can only really support one target at once (unless you have an objdump built with support for al bfd targets).
Looks like that's not a new change in this Diff. but something we might want to change in the future.

This revision is now accepted and ready to land.Nov 29 2021, 12:27 AM

So by depending on objdump it does mean you can only really support one target at once (unless you have an objdump built with support for al bfd targets).
Looks like that's not a new change in this Diff. but something we might want to change in the future.

I just realized that this is only done so during the profile upgrade so this is fine. disregard :)

This revision was automatically updated to reflect the committed changes.