Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


undefined reference to sbrk

puntinopuntino Member Posts: 1
I have tried to sort out the "unbdefined reference sbrk" message. First my system comfiguration, then my attempts. I have to build an executable (elf file) for powerpc with gnu-gcc 4.2.2. installed on windows XP. The tool chain works properly because I already managed to build several other projects without using function with dynamic allocation (e.g., malloc). The options that I use for compilaing: -gdwarf-2 -c -fno-exceptions -finline linking: -nostartfiles -v -Xlinker --output=$(OUTPUTFILE) -Xlinker -Map=map.txt -Xlinker --script=$(INDPATH) -lc -lm (INDPATH points to my linker script file).

To sort the problem, I have written my bsrk implementaion in a file, systemcall.c that is part of my project. Then, I modified also the script file to add the heap section.

I build the project with the former link option and I still get the same error.

I build with -nostartfiles -v -Xlinker --output=$(OUTPUTFILE) -Xlinker -Map=map.txt -Xlinker --script=$(INDPATH) -o systemcall.o -lc -lm , error again

I build with -nostartfiles -v -Xlinker --output=$(OUTPUTFILE) -Xlinker -Map=map.txt -Xlinker --script=$(INDPATH) -lc -lm -lyk -> NO ERROR, but when I run the program it gets stuck after I call the malloc function. I tried to find out on -lyk, but I haven't found satisfing info. I suspect that option provides a stub to the compiler with the _bsrk symbol, thus the compiler doesn't complain, but an actual implementation is missing.

How can I sort this problem? Another attemp that I was thinking of doing is to create from systemcall.o a static library and force the linker to link it wit -l option (or -L if I do not place the library in the "sys" folder). Any help is appreciated, thank you.

Sign In or Register to comment.