]> Zhao Yanbai Git Server - minix.git/commitdiff
gold -Ttext=.. workaround
authorBen Gras <ben@minix3.org>
Wed, 19 Mar 2014 23:01:48 +0000 (00:01 +0100)
committerLionel Sambuc <lionel@minix3.org>
Mon, 28 Jul 2014 15:05:50 +0000 (17:05 +0200)
replace invocations of -Ttext=.. with --section-start=.text=.. for
gnu gold-ld. it was giving very weird results when given page-rounded
values. --section-start=.text=.. works for both bfd-ld and gold.

sys/arch/i386/stand/boot/Makefile.boot
sys/arch/i386/stand/bootxx/Makefile.bootxx
sys/arch/i386/stand/cdboot/Makefile
sys/arch/i386/stand/mbr/Makefile.mbr

index a0b4608655bc02d5a6566bf6db3794466bbdb8f6..68b687e83cd316d26dbf895861ab579cd7fa7c00 100644 (file)
@@ -137,12 +137,18 @@ CLEANFILES+= ${PROG}.tmp ${PROG}.map ${PROG}.syms vers.c
 vers.c: ${VERSIONFILE} ${SOURCES} ${LIBLIST} ${.CURDIR}/../Makefile.boot
        ${HOST_SH} ${S}/conf/newvers_stand.sh ${VERSIONFILE} x86 ${NEWVERSWHAT}
 
+.if defined(__MINIX)
+# BJG
+# -Wl,-Ttext,0 changed to --section-start=.text=0 twice below of a gold problem.
+# did not leave both versions in because of the huge continued line.
+.endif
+
 # Anything that calls 'real_to_prot' must have a %pc < 0x10000.
 # We link the program, find the callers (all in libi386), then
 # explicitly pull in the required objects before any other library code.
 ${PROG}: ${OBJS} ${LIBLIST} ${.CURDIR}/../Makefile.boot
        ${_MKTARGET_LINK}
-       bb="$$( ${CC} -o ${PROG}.syms ${LDFLAGS} -Wl,-Ttext,0 -Wl,-cref \
+       bb="$$( ${CC} -o ${PROG}.syms ${LDFLAGS} -Wl,--section-start=.text=0 -Wl,-cref \
            ${OBJS} ${LIBLIST} | ( \
                while read symbol file; do \
                        [ -z "$$file" ] && continue; \
@@ -158,7 +164,7 @@ ${PROG}: ${OBJS} ${LIBLIST} ${.CURDIR}/../Makefile.boot
                do :; \
                done; \
        ) )"; \
-       ${CC} -o ${PROG}.syms ${LDFLAGS} -Wl,-Ttext,0 \
+       ${CC} -o ${PROG}.syms ${LDFLAGS} -Wl,--section-start=.text=0 \
                -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} $$bb ${LIBLIST}
        ${OBJCOPY} -O binary ${PROG}.syms ${PROG}
 
index 0eedfe0388d93d225475b675bd6b0e00c6ab44e0..52abc5b9a6be68d85a90a33ad7396dd34010a991 100644 (file)
@@ -140,8 +140,13 @@ CLEANFILES+= ${PROG}.sym ${PROG}.map
 
 ${PROG}: ${OBJS} ${LIBLIST}
        ${_MKTARGET_LINK}
+.if defined(__MINIX)
+       ${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,--section-start=.text=${PRIMARY_LOAD_ADDRESS} \
+               -T ${LDSCRIPT} -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST}
+.else
        ${CC} -o ${PROG}.sym ${LDFLAGS} -Wl,-Ttext,${PRIMARY_LOAD_ADDRESS} \
                -T ${LDSCRIPT} -Wl,-Map,${PROG}.map -Wl,-cref ${OBJS} ${LIBLIST}
+.endif
        ${OBJCOPY} -O binary ${PROG}.sym ${PROG}
        @ sz=$$(${TOOL_STAT} -f '%z' ${PROG}); \
        if [ "$$sz" -gt "${BOOTXX_MAXSIZE}" ]; then \
index 1662c180bed62b7954d8b4503361e39b6f0c7595..db7b13c23283e156febe96cbb1ffc0538fb0bcd5 100644 (file)
@@ -53,8 +53,13 @@ CLEANFILES+= ${PROG}.tmp
 
 ${PROG}: ${OBJS}
        ${_MKTARGET_LINK}
+.if defined(__MINIX)
+       ${CC} -o ${PROG}.tmp ${LDFLAGS} -Wl,--section-start=.text=${PRIMARY_LOAD_ADDRESS} \
+           ${OBJS}
+.else
        ${CC} -o ${PROG}.tmp ${LDFLAGS} -Wl,-Ttext,${PRIMARY_LOAD_ADDRESS} \
            ${OBJS}
+.endif
        @ set -- $$( ${NM} -t d ${PROG}.tmp | grep '\<free_space\>' \
                | ${TOOL_SED} 's/^0*//'  ); \
                echo "#### There are $$1 free bytes in ${PROG}"
index 59743b2a62c84a309149213eb88fc3dad7ef896a..c91e700a3bb3574bc456500cba8c86641191b55d 100644 (file)
@@ -56,7 +56,11 @@ AFLAGS.gpt.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
 
 ${PROG}: ${OBJS}
        ${_MKTARGET_LINK}
+.if defined(__MINIX)
+       ${CC} -o ${PROG}.tmp ${LDFLAGS} -Wl,--section-start=.text=${LOADADDR} ${OBJS}
+.else
        ${CC} -o ${PROG}.tmp ${LDFLAGS} -Wl,-Ttext,${LOADADDR} ${OBJS}
+.endif
        @ set -- $$( ${NM} -t d ${PROG}.tmp | grep '\<mbr_space\>' \
                    | ${TOOL_SED} 's/^0*//'  ); \
                echo "#### There are $$1 free bytes in ${PROG}"