All of lore.kernel.org
 help / color / mirror / Atom feed
From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] ARM: Add .data/.rodata/.bss section starts to gd_t
Date: Thu, 01 Mar 2012 15:22:47 +0100	[thread overview]
Message-ID: <4F4F8637.3080805@aribaud.net> (raw)
In-Reply-To: <4F4E5585.3070900@logicpd.com>

Hi Peter,

Le 29/02/2012 17:42, Peter Barada a ?crit :
> On 02/28/2012 05:04 PM, Albert ARIBAUD wrote:
>> Hi Peter,
>>
>> Le 27/02/2012 23:00, Peter Barada a ?crit :
>>> When debugging u-boot, after relocation its tedious to calculate positions
>>> of the various sections (.data, .rodata, .bss).  To make it easier, add
>>> the structure "sections" to gd_t that contains the relocated start of
>>> those sections.  Then the gdb command "add-symbol-file" can by used with
>>> "-s<section>   <address>" that corresponds to the values in gd_t->sections.
>> NAK until I get an explanation and usage scenario for this, because I've
>> never had to do calculations on sections so far, so I want to understand
>> why it would be needed.
>>
>> Amicalement,
> Weird.  Digging further its looking more like a problem with GDB...
>
> I'm using the CodeSourcery 2009q1-203 toolchain (for ARM), and
> "add-symbol-file u-boot 0x...." only relocated symbols in the .text
> segment, not .data, .rodata, and .bss sections.  Looking at newer
> toolchains (CodeSourcery 2011.09-70) I see even stranger results:
>
> Current directory is /home/peter/work/logic/git/u-boot-branches/
> GNU gdb (Sourcery CodeBench Lite 2011.09-70) 7.2.50.20100908-cvs
> Copyright (C) 2010 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "--host=i686-pc-linux-gnu
> --target=arm-none-linux-gnueabi".
> For bug reporting instructions, please see:
> <https://support.codesourcery.com/GNUToolchain/>...
> Reading symbols from
> /home/peter/work/logic/git/u-boot-branches/u-boot...done.
> (gdb) info file
> Symbols from "/home/peter/work/logic/git/u-boot-branches/u-boot".
> Local exec file:
>      `/home/peter/work/logic/git/u-boot-branches/u-boot', file type
> elf32-littlearm.
>      Entry point: 0x80100000
>      0x80100000 - 0x80124a30 is .text
>      0x80124a30 - 0x8012d43a is .rodata
>      0x8012d43c - 0x8012d488 is .hash
>      0x8012d488 - 0x8012dee0 is .data
>      0x8012dee0 - 0x8012deec is .got.plt
>      0x8012deec - 0x8012e544 is .u_boot_cmd
>      0x8013354c - 0x8013362c is .dynsym
>      0x8012e544 - 0x8013354c is .rel.dyn
>      0x8012e544 - 0x80165388 is .bss
> (gdb)(gdb) symbol-file
> Discard symbol table from
> `/home/peter/work/logic/git/u-boot-branches/u-boot'? (y or n) y
> No symbol file now.
> (gdb) *add-symbol-file u-boot 0x8ff8a000 -readnow -s .rodata 0x8FFAEA30
> -s .data 0x8FFB7488 -s .bss 0x8FFB8544*
> add symbol table from file "u-boot" at
>      .text_addr = 0x8ff8a000
>      .rodata_addr = 0x8ffaea30
>      .data_addr = 0x8ffb7488
>      .bss_addr = 0x8ffb8544
> (y or n) y
> Reading symbols from
> /home/peter/work/logic/git/u-boot-branches/u-boot...expanding to full
> symbols...done.
> (gdb) *p&stdio_devices*
> $26 = (struct stdio_dev *(*)[3]) *0x80131c0c*
> (gdb) info sym stdio_devices
> __rel_dyn_start + 14024 in section .rel.dyn
> (gdb) info sym boards
> boards in section .data
> (gdb) p *&boards*
> $27 = (struct board_id (*)[2][2]) *0x8ffb7ec0*
> (gdb) shell nm u-boot | grep stdio_devices
> *80131c0c* B stdio_devices
> (gdb) shell nm u-boot | grep boards
> *8012dec0* d boards
> (gdb)
>
> Note that "boards" gets properly relocated whereas "stdio_devices" does
> not - apparently a lot (all?) of the .bss symbols are not properly
> relocated.  Hmm, I wonder if this is caused by .rel.dyn overlaing .bss...
>
> Which version of GDB are you using on ARM that properly relocates all
> the sections after "add-symbol-file u-boot<addr>"?

I routinely use ELDK42 (4.2.2 toochain) and stcok (linaro) Ubuntu 
(4.6.1). I don't remember having hit this issue -- although I am hitting 
another one where breakpoints are set 4 or 8 bytes further than they 
should, but the symbols themselves are ok; but I rarely use global .data 
or .bss symbols, so I may have missed the issue.

Anyway, 'help add-symbol-file' says a single address applies to 
consecutive sections, so until it is sorted out with the GDB people why 
this does not work, my NAK still holds.

Amicalement,
-- 
Albert.

  reply	other threads:[~2012-03-01 14:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-27 22:00 [U-Boot] [PATCH] ARM: Add .data/.rodata/.bss section starts to gd_t Peter Barada
2012-02-28 22:04 ` Albert ARIBAUD
2012-02-29 16:42   ` Peter Barada
2012-03-01 14:22     ` Albert ARIBAUD [this message]
2012-03-01 15:57       ` Peter Barada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F4F8637.3080805@aribaud.net \
    --to=albert.u.boot@aribaud.net \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.