gold -Ttext=.. workaround

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.
This commit is contained in:
Ben Gras 2014-03-20 00:01:48 +01:00 committed by Lionel Sambuc
parent 4a71196e69
commit 6611dddc31
4 changed files with 22 additions and 2 deletions

View 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}

View 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 \

View 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}"

View 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}"