[U-Boot-Users] .bss segment problem

k b k_bisla at hotmail.com
Wed Jun 21 20:04:49 CEST 2006


Hi Wolfgank,
Thanks for you inputs. please see my response below.

>When are you calling this function - before or after relocation  to
>RAM?
i call this after relocation.

Also in the .c file (see snippet below)

   static u8 pktbuf_raw[RAWBUF_SIZE];
   static pkt_info pktbuf_i;
   pkt_info pktbuf_di;

   typedef struct pkt_info_t {
       u8 *buf
       u8 *data;
       ...
   } pkt_info;


    void someFunction(void)
    {
       .
       .
       .
       .
LINE A >> pktbuf_i.data[0] = 20;
          printf("0x%d\n", pktbuf_i.data[0], pktbuf_i.data);
    }

   void initialize()
   {
         / pkt_info init_pktbuf_i = {
         |      .buf = pktbuf_raw,
LINES X -|
         |      .data = pktbuf_raw + DMTP_HDR_SIZE,
         \ };

            memcpy(&pktbuf_i, &init_pktbuf_i, sizeof(pkt_info));
Line B >>>  printf("pktbuf_i 0x%x 0x%x\n", pktbuf_i.data, pktbuf_raw);
   }

i print the address the of pktbuf_i and pktbuf_raw in line B, which are the 
same
even after relocation. should it be same address ? I would think the addres 
sould change. is that right ?

> > Also if you look closely the at .bss segment below(most of output from
> > objdump),
> > the address aren't continuous some are 01dbe8f0 or 03bdee14 to fffced00.
> > which looks strange.
>
>Well, they ARE continuous.
>"scd_modbuf" is HUGE - 28 MB!
hmm, yeah i see now the address are wrapping around.
scd_modbuf is a file buffer. i shrunk it to 1 MB which had no effect.


So my questions are :-

1) I print the address the of pktbuf_i and pktbuf_raw in line B, which are 
the same
    even after relocation. should it be same address ? I would think the 
addres sould change. is that right ?

2) Also another interesting think i did ... with keeping the scd_modbuf to 
28 MB,
but changing the way the struct is initialized. Diffrent from LINES X.

   void initialize()
   {
             _
            /  pkt_info init_pktbuf_i;
new lines   |  init_pktbuf_i.buf = pktbuf_raw,
            |
            \_ init_pktbuf_i.data = pktbuf_raw + DMTP_HDR_SIZE,
        memcpy(&pktbuf_i, &init_pktbuf_i, sizeof(pkt_info));
        printf("pktbuf_i 0x%x 0x%x\n", pktbuf_i.data, pktbuf_raw); <<<<< 
LINE B
   }

this change make everythink to work. Any idea ?. Seems like a compiler being 
finiky.
I'm using "ppc_440-gcc (GCC) 3.3.1".
But the old way (i.e. of intializing as in LINES X) with 28 MB scd_modbuf 
and with the same toolchain
worked in U-boot-1.0.0 until we upgraded.

what do you think ?

Thanks for all you inputs i really appreciate it.

Kunal Bisla.






More information about the U-Boot mailing list