Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 May 2011 16:38:45 GMT
From:      Damjan Marion <damjan.marion@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   arm/156771: FreeBSD/arm fails to build trampoline code with clang due to missing -ffreestanding
Message-ID:  <201105021638.p42Gcj7f071073@red.freebsd.org>
Resent-Message-ID: <201105021640.p42GeAvI070046@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         156771
>Category:       arm
>Synopsis:       FreeBSD/arm fails to build trampoline code with clang due to missing -ffreestanding
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-arm
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 02 16:40:10 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Damjan Marion
>Release:        -CURRENT
>Organization:
n/a
>Environment:
>Description:

clang compiler produces optimized code which calls memset which is missing when kernel.trampoline is linked.

inflate-tramp.o: In function `inflate_dynamic':
/Volumes/data/src/freebsd/sys/kern/inflate.c:(.text+0x538): undefined reference to `memset'
inflate-tramp.o: In function `huft_build':
/Volumes/data/src/freebsd/sys/kern/inflate.c:(.text+0xb1c): undefined reference to `memset'


This can be avoided by passing -ffreestanding (diff attached). 

>How-To-Repeat:

>Fix:
diff --git a/sys/conf/Makefile.arm b/sys/conf/Makefile.arm
index 756945d..d067fb3 100644
--- a/sys/conf/Makefile.arm
+++ b/sys/conf/Makefile.arm
@@ -108,7 +108,7 @@ ${KERNEL_KO}.tramp: ${KERNEL_KO} $S/$M/$M/inckern.S $S/$M/$M/elf_trampoline.c
        gzip -9 ${KERNEL_KO}.tmp
        eval $$(stat -s ${KERNEL_KO}.tmp.gz) && \
        echo "#define KERNCOMPSIZE $$st_size" >>opt_kernname.h
-       ${CC} -O2 -DKZIP -I. -I$S -c $S/kern/inflate.c -o inflate-tramp.o
+       ${CC} -O2 -ffreestanding -DKZIP -I. -I$S -c $S/kern/inflate.c -o inflate-tramp.o
        ${CC} -O -nostdlib -I. -I$S -Xlinker -T -Xlinker ldscript.$M.tramp \
        -DKZIP tmphack.S $S/$M/$M/elf_trampoline.c inflate-tramp.o \
        $S/$M/$M/inckern.S ${FILES_CPU_FUNC} -o ${KERNEL_KO}.gz.tramp


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105021638.p42Gcj7f071073>