[U-Boot] using objdump/readelf/nm to dump symbols by individual source file?

Robert P. J. Day rpjday at crashcourse.ca
Mon Apr 8 08:07:46 UTC 2019


On Mon, 8 Apr 2019, Chris Packham wrote:

> On Mon, Apr 8, 2019 at 7:45 PM Chris Packham <judge.packham at gmail.com> wrote:
> >
> > On Mon, Apr 8, 2019 at 4:29 AM Robert P. J. Day <rpjday at crashcourse.ca> wrote:
> > >
> > >
> > >   i'm doing this in the context of building for ARM with a linaro
> > > toolchain, but i'm sure it's equally valid in the context of a native
> > > build.
> > >
> > >   i'm trying to generate the same output as u-boot.map, but more
> > > condensed and with each symbol associated with its original source
> > > file (if that's even possible).
> > >
> > >   for example, there are a couple weak symbols in board_f.c:
> > >
> > >   __weak int arch_cpu_init(void)
> > >   {
> > >         return 0;
> > >   }
> > >
> > >   __weak int mach_cpu_init(void)
> > >   {
> > >         return 0;
> > >   }
> > >
> > > so depending on the target board, the final included version of such a
> > > routine might come from board_f.c, or it might be overridden at the
> > > board level.
> > >
> > >   you can sort of see this in u-boot.map:
> > >
> > >  .text.arch_cpu_init
> > >                 0x0000000000000000        0x8 common/built-in.o
> > >
> > >  ...
> > >  .text.mach_cpu_init
> > >                 0x0000000004011cac        0x8 common/built-in.o
> > >                 0x0000000004011cac                mach_cpu_init
> > >
> > > except i was hoping to be able to list included symbols by their
> > > *original* source file, and listed one file at a time, so the output
> > > would have the format:
> > >
> > >   board_f.o
> > >     mach_cpu_init
> > >     ... other stuff from board_f.o
> > >
> > > i could swear i once knew how to do this, but i've forgotten (or
> > > perhaps i'm misremembering). is there some variation of objdump,
> > > readelf or nm that will do what i want? i need nothing other than, for
> > > each source file, the symbols that were included in the final ELF file
> > > from that source file.
> > >
> > >   can i do this?
> > >
> >
> > nm -l u-boot seems to give me what you're asking for
> >
> >
> > $ nm -l u-boot
> > 0089b8d8 b a_b  /home/chrisp/src/u-boot/cmd/load.c:573
> > 0089f62c b act.10860
> > 00857780 t add_ino      /home/chrisp/src/u-boot/fs/ubifs/recovery.c:1261
> > 00828b34 T add_mtd_device
> > /home/chrisp/src/u-boot/drivers/mtd/mtdcore.c:410
> > 00829f7c T add_mtd_partitions
> > /home/chrisp/src/u-boot/drivers/mtd/mtdpart.c:865
> > 00835b2c t add_to_list
> > 0085188c t adjust_lpt_heap.isra.1
> > /home/chrisp/src/u-boot/fs/ubifs/lprops.c:635
> > 0086b110 T adler32
> > 008775e0 T __aeabi_idiv /home/chrisp/src/u-boot/arch/arm/lib/lib1funcs.S:251
> > 008776c4 T __aeabi_idivmod
> > /home/chrisp/src/u-boot/arch/arm/lib/lib1funcs.S:340
> > 00877544 T __aeabi_uidiv
> > /home/chrisp/src/u-boot/arch/arm/lib/lib1funcs.S:199
> > 008776ac T __aeabi_uidivmod
> > /home/chrisp/src/u-boot/arch/arm/lib/lib1funcs.S:324
> > 008776ec T __aeabi_uldivmod
> > /home/chrisp/src/u-boot/arch/arm/lib/uldivmod.S:38
> > 00820fd4 t alloc_priv
> > 0081ac20 t alloc_simple /home/chrisp/src/u-boot/common/malloc_simple.c:17
>
> Just re-read your question. You might need to do some post processing
> to group by the source file.

  yes, that's the info i'm after, i could swear i once identified a
command that would give it to me in the format i was suggesting. or
perhaps i'm misremembering. thanks.

rday


More information about the U-Boot mailing list