Page 1 of 1

Relocatable elf problem

Posted: Sun May 01, 2016 8:35 am
by digo_rp
Hi all, I,m having some problem... let-me try to explain.

I have 2 case!

case 1: using .bss non initialized var.

unsigned char cmdargs[10][32];

memset((unsigned char *)&cmdargs, 0, sizeof(cmdargs));

this at my os, I can use a lot! no problem!

bute when I try to put my CommandLineInterpreter inside in a elf relocatable file and try to do a memset like above... all my operating system goes crazy...

and case 2:

unsigned char cmdargs[10][32] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

memset((unsigned char *)&cmdargs, 0, sizeof(cmdargs));

at this case my Command Line Interpreter works fine inside in a .elf relocatable file...

with this second case my var cmdargs goes into .data section, right ? and other on not initialized in case one goes into .bss section...

now I donĀ“t understand why that happens...

could anyone help me trying to solve that mistake! please!

tnx a lot and forgive-me all common mistakes...

Re: Relocatable elf problem

Posted: Mon May 09, 2016 7:15 pm
by digo_rp
OK! the problem was solved!

I found this on OSD tutorials.

ld option -d is equivalent to the FORCE_COMMON_ALLOCATION command in a linker script

this happens on global vars that are not initialized.

thnx so much all.

Re: Relocatable elf problem

Posted: Mon May 09, 2016 7:33 pm
by kzinti
digo_rp wrote:thnx so much all.
You are welcome!