0002-force-cxx-compiler.patch 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. Subject: [PATCH 1/1] elftosb: force host C++ compiler
  2. Because Freescale provides *.cpp sources and elftosb links again libstdc++,
  3. force to use the host c++ compiler.
  4. This patch avoids the following error occurs:
  5. 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
  6. /usr/bin/ld: ElftosbAST.o: undefined reference to symbol 'powf@@GLIBC_2.2.5'
  7. /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
  8. /lib64/libm.so.6: could not read symbols: Invalid operation
  9. collect2: error: ld returned 1 exit status
  10. When compiling with gcc and linking against libstdc++, ld uses libc instead of
  11. libstdc++.
  12. However, libc does not provide all functions libstdc++ does.
  13. Indeed, maths functions are provided by libm, not libc.
  14. Thus, elftosb should either:
  15. - use gcc and link against libc and libm;
  16. - or use g++ and link against libstdc++.
  17. Because elftosb is written in C++, this patch implement the sencond option, using
  18. g++ and linking against libstdc++.
  19. Signed-off-by: Samuel Martin <s.martin49@gmail.com>
  20. ---
  21. Index: host-elftosb-10.12.01/makefile.rules
  22. ===================================================================
  23. --- host-elftosb-10.12.01.orig/makefile.rules 2012-06-09 21:12:23.557526100 +0200
  24. +++ host-elftosb-10.12.01/makefile.rules 2012-06-09 21:15:21.659894571 +0200
  25. @@ -15,6 +15,8 @@
  26. # UNAMES is going to be set to either "Linux" or "CYGWIN_NT-5.1"
  27. UNAMES = $(shell uname -s)
  28. +CXX ?= g++
  29. +
  30. #*******************************************************************************
  31. # Directories
  32. @@ -37,9 +39,9 @@
  33. #*******************************************************************************
  34. # Build flags
  35. -# gcc Compiler flags
  36. +# Compiler flags
  37. # -g : Produce debugging information.
  38. -CFLAGS = -g $(INC_PATH) -D${UNAMES}
  39. +CXXFLAGS = -g $(INC_PATH) -D${UNAMES}
  40. #*******************************************************************************
  41. # File lists
  42. @@ -137,13 +139,13 @@ clean:
  43. ${EXEC_FILE_ELFTOSB2} ${EXEC_FILE_SBTOOL} ${EXEC_FILE_KEYGEN}
  44. elftosb: ${OBJ_FILES_ELFTOSB2}
  45. - gcc ${OBJ_FILES_ELFTOSB2} ${LIBS} -o ${EXEC_FILE_ELFTOSB2}
  46. + $(CXX) ${OBJ_FILES_ELFTOSB2} ${LIBS} -o ${EXEC_FILE_ELFTOSB2}
  47. sbtool: ${OBJ_FILES_SBTOOL}
  48. - gcc ${OBJ_FILES_SBTOOL} ${LIBS} -o ${EXEC_FILE_SBTOOL}
  49. + $(CXX) ${OBJ_FILES_SBTOOL} ${LIBS} -o ${EXEC_FILE_SBTOOL}
  50. keygen: ${OBJ_FILES_KEYGEN}
  51. - gcc ${OBJ_FILES_KEYGEN} ${LIBS} -o ${EXEC_FILE_KEYGEN}
  52. + $(CXX) ${OBJ_FILES_KEYGEN} ${LIBS} -o ${EXEC_FILE_KEYGEN}
  53. #ifeq ("${UNAMES}", "Linux")
  54. @@ -153,10 +155,10 @@ keygen: ${OBJ_FILES_KEYGEN}
  55. .SUFFIXES : .c .cpp
  56. .c.o :
  57. - gcc ${CFLAGS} -c $<
  58. + $(CC) ${CXXFLAGS} -c $<
  59. .cpp.o :
  60. - gcc ${CFLAGS} -c $<
  61. + $(CXX) ${CXXFLAGS} -c $<
  62. #endif
  63. @@ -165,13 +167,13 @@ keygen: ${OBJ_FILES_KEYGEN}
  64. %.d: %.c
  65. @set -e; \
  66. - $(CC) -MM $(CFLAGS) $< | \
  67. + $(CC) -MM $(CXXFLAGS) $< | \
  68. sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
  69. [ -s $@ ] || rm -f $@
  70. %.d: %.cpp
  71. @set -e; \
  72. - $(CC) -MM $(CFLAGS) $< | \
  73. + $(CXX) -MM $(CXXFLAGS) $< | \
  74. sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
  75. [ -s $@ ] || rm -f $@