Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

undefined reference to sbrk

puntinopuntino Posts: 1Member
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.