lkml.org 
[lkml]   [2009]   [Nov]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Easier way to generate stuff like asm-offsets.
On Fri, Nov 20, 2009 at 04:56:14PM -0800, Kaz Kylheku wrote:
>
> Here is the simple trick:
....
>
> Now we compile test.c:
>
> $ /path/to/toolchain/bin/arch-prefix-gcc test.c -c
>
> Then we can use the ``nm'' tool (the toolchain should have binutils in it):
>
> $ /path/to/toolchain/bin/arch-prefix-nm -t d -P foo.c # decimal
> output, posix format
> offsetof_foo_member C 00000044 00000044
>
> There we go, 44 bytes. Simple. This is almost an #include file;
> we just have to do some simple filtering, such as:
>
> $ /path/to/toolchain/bin/arch-prefix-nm -t d -P test.o | awk '{ print "#define", $1, $4 }'
> #define offsetof_foo_member 00000044

If that is a "decimal output" then resulting define has a wrong format.
You do not want octal. Fix that with
... | awk '{print "#define", $1, 0 + $4}'
to force a conversion of a string to a number.

Michal


\
 
 \ /
  Last update: 2009-11-21 08:17    [W:0.036 / U:0.856 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site