[coreboot] GSOC USBROM linking problem
Jason Wang
wangqingpei at gmail.com
Tue Jun 16 20:17:46 CEST 2009
Hi ROM,
When I am trying to use libpayload in my own usbrom, i find that I the
function point seems wrong. In my main.c files:
int main(int argc, char **argv){
const char *s="foo";
console_init();
puts(s);//the address of s which should passed to puts was wrong
//// I check it with HDT find it move address 262c to[esp].
while(1);
return 0;
}
I really do not know why, and my ldscript is
OUTPUT_FORMAT("elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_setup)
/* 32KB heap and 16KB stack */
HEAP_SIZE = 32768;
STACK_SIZE = 16384;
__boot_vect = 0x0000;
SECTIONS
{
.text __boot_vect :
{
*( .text)
} = 0x00
.rodata ALIGN(4) :
{
*( .rodata)
} = 0x00
.data ALIGN(4) :
{
*( .data)
} = 0x00
.bss ALIGN(4) :
{
*( .bss)
/* heap and stack */
. = ALIGN(16);
_heap = .;
. += HEAP_SIZE;
. = ALIGN(16);
_eheap = .;
_stack = .;
. += STACK_SIZE;
. = ALIGN(16);
_estack = .;
} = 0x00
}
and Makefile is
export obj := $(shell pwd)/build
export src := $(shell pwd)/src
export build := $(shell pwd)/build
ifeq ($(V),1)
Q := @
endif
TARGETS-y := head.o main.o
OBJS := $(patsubst %,$(obj)/%,$(TARGETS-y))
ROM_OBJ= $(obj)/usb.rom
ROM_BIN= $(obj)/usb.bin
ROM_SIZE= 65536
OBJCOPY= objcopy
OBJCOPY_FLAGS= -O binary
BUILD_ROM= ./build_rom
LIBPAYLOAD_PREFIX= /opt/libpayload
LIBPAYLOAD=$(LIBPAYLOAD_PREFIX)/lib/libpayload.a
INCPAYLOAD=$(LIBPAYLOAD_PREFIX)/include/
STACKPROTECT += $(call cc-option, -fno-stack-protector,)
GCCINCDIR = $(shell $(CC) -print-search-dirs | head -n 1 | cut -d' '
-f2)include/
INCLUDES := -I$(INCPAYLOAD) -Iinclude -Ibuild
INCLUDES += -Iinclude -Ibuild
INCLUDES += -I$(GCCINCDIR) -I$(INCPAYLOAD)/i386/
CFLAGS += -Wall $(STACKPROTECT) $(INCLUDES) -c -fno-builtin -nostdinc
-Werror -Os -fomit-frame-pointer -fno-common -ffreestanding
-fno-strict-aliasing
CFLAGS= $(STACKPROTECT) $(INCLUDES) -c -fno-builtin -nostdinc -O2 -I. -Wall
-Werror
LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
all:$(ROM_BIN)
$(ROM_BIN): $(OBJS)
$(Q)printf " LD $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(LD) -T $(src)/ldscript -static -o $@ $(OBJS) $(LIBPAYLOAD)
$(LIBGCC)
$(Q)$(OBJCOPY) $(OBJCOPY_FLAGS) $(ROM_BIN) $(ROM_OBJ)
$(Q)$(BUILD_ROM) $(ROM_OBJ) $(ROM_SIZE)
$(obj)/%.o: $(src)/%.c
$(Q)printf " CC $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
$(obj)/%.o: $(src)/%.S
$(Q)printf " AS $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(AS) -o $@ $<
prepare:
$(Q)printf " SH building/preparing libpayload\n"
$(Q)./prepare.sh
clean:
$(Q)printf " SH cleaning $(obj)\n"
$(Q)rm -f $(obj)/*.o $(obj)/*.rom $(obj)/*.bin
distclean: clean
$(Q)printf " SH cleaning $(src)\n"
@rm -Rf build
@rm -Rf libpayload
i also attached all of my source file. Could you please help me to take a
look at this? Thanks.
--
Jason Wang
Peking University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20090617/597a7fe1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: usbrom.tar.gz
Type: application/x-gzip
Size: 56207 bytes
Desc: not available
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20090617/597a7fe1/attachment.gz>
More information about the coreboot
mailing list