blob: efa92d11713179a0d4892060eb9da5f451c0acdf [file] [log] [blame]
Subject: [PATCH] elftosb: force host C++ compiler
Because Freescale provides *.cpp sources and elftosb links again libstdc++,
force to use the host c++ compiler.
This patch avoids the following error occurs:
gcc AESKey.o Blob.o crc.o DataSource.o DataTarget.o ELFSourceFile.o EncoreBootImage.o EvalContext.o GHSSecInfo.o GlobMatcher.o HexValues.o Logging.o Operation.o OptionDictionary.o options.o OutputSection.o Random.o RijndaelCBCMAC.o rijndael.o SHA1.o SourceFile.o SRecordSourceFile.o stdafx.o StELFFile.o StExecutableImage.o StSRecordFile.o Value.o Version.o format_string.o ExcludesListMatcher.o SearchPath.o DataSourceImager.o IVTDataSource.o BootImageGenerator.o ConversionController.o ElftosbAST.o elftosb.o elftosb_lexer.o ElftosbLexer.o elftosb_parser.tab.o EncoreBootImageGenerator.o -lstdc++ -o elftosb
/usr/bin/ld: ElftosbAST.o: undefined reference to symbol 'powf@@GLIBC_2.2.5'
/usr/bin/ld: note: 'powf@@GLIBC_2.2.5' is defined in DSO /lib64/libm.so.6 so try adding it to the linker command line
/lib64/libm.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
When compiling with gcc and linking against libstdc++, ld uses libc instead of
libstdc++.
However, libc does not provide all functions libstdc++ does.
Indeed, maths functions are provided by libm, not libc.
Thus, elftosb should either:
- use gcc and link against libc and libm;
- or use g++ and link against libstdc++.
Because elftosb is written in C++, this patch implement the sencond option, using
g++ and linking against libstdc++.
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
---
Index: host-elftosb-10.12.01/makefile.rules
===================================================================
--- host-elftosb-10.12.01.orig/makefile.rules 2012-06-09 21:12:23.557526100 +0200
+++ host-elftosb-10.12.01/makefile.rules 2012-06-09 21:15:21.659894571 +0200
@@ -15,6 +15,8 @@
# UNAMES is going to be set to either "Linux" or "CYGWIN_NT-5.1"
UNAMES = $(shell uname -s)
+CXX ?= g++
+
#*******************************************************************************
# Directories
@@ -37,9 +39,9 @@
#*******************************************************************************
# Build flags
-# gcc Compiler flags
+# Compiler flags
# -g : Produce debugging information.
-CFLAGS = -g $(INC_PATH) -D${UNAMES}
+CXXFLAGS = -g $(INC_PATH) -D${UNAMES}
#*******************************************************************************
# File lists
@@ -137,13 +139,13 @@ clean:
${EXEC_FILE_ELFTOSB2} ${EXEC_FILE_SBTOOL} ${EXEC_FILE_KEYGEN}
elftosb: ${OBJ_FILES_ELFTOSB2}
- gcc ${OBJ_FILES_ELFTOSB2} ${LIBS} -o ${EXEC_FILE_ELFTOSB2}
+ $(CXX) ${OBJ_FILES_ELFTOSB2} ${LIBS} -o ${EXEC_FILE_ELFTOSB2}
sbtool: ${OBJ_FILES_SBTOOL}
- gcc ${OBJ_FILES_SBTOOL} ${LIBS} -o ${EXEC_FILE_SBTOOL}
+ $(CXX) ${OBJ_FILES_SBTOOL} ${LIBS} -o ${EXEC_FILE_SBTOOL}
keygen: ${OBJ_FILES_KEYGEN}
- gcc ${OBJ_FILES_KEYGEN} ${LIBS} -o ${EXEC_FILE_KEYGEN}
+ $(CXX) ${OBJ_FILES_KEYGEN} ${LIBS} -o ${EXEC_FILE_KEYGEN}
#ifeq ("${UNAMES}", "Linux")
@@ -153,10 +155,10 @@ keygen: ${OBJ_FILES_KEYGEN}
.SUFFIXES : .c .cpp
.c.o :
- gcc ${CFLAGS} -c $<
+ $(CC) ${CXXFLAGS} -c $<
.cpp.o :
- gcc ${CFLAGS} -c $<
+ $(CXX) ${CXXFLAGS} -c $<
#endif
@@ -165,13 +167,13 @@ keygen: ${OBJ_FILES_KEYGEN}
%.d: %.c
@set -e; \
- $(CC) -MM $(CFLAGS) $< | \
+ $(CC) -MM $(CXXFLAGS) $< | \
sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
[ -s $@ ] || rm -f $@
%.d: %.cpp
@set -e; \
- $(CC) -MM $(CFLAGS) $< | \
+ $(CXX) -MM $(CXXFLAGS) $< | \
sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
[ -s $@ ] || rm -f $@