Problem
I get this error when compiling a C++ program:
patch: file modulus: cannot get .data header CC: error: patch failed in handling static constructors or destructors
I am generating one or more elf binaries when compiling.
Solution
You must specify "-b elf" at the link stage as well as at the
compile stage. For example, the following makefile will generate
this error:modulus: modulus.o test.o
CC -o modulus modulus.o test.omodulus.o: modulus.C modulus.h
CC -c -b elf modulus.Ctest.o: test.C modulus.h
CC -c test.CChange the link line to include "-b elf":
modulus: modulus.o test.o
CC -o -b elf modulus modulus.o test.o
^^^^^
modulus.o: modulus.C modulus.h
CC -c -b elf modulus.Ctest.o: test.C modulus.h
CC -c test.C