Workaround crash due to gcc stack alignment requirements (bb #2270).

GCC (4.4 at least) requires and creates functions with 16-byte stack alignment
on 32-bit Linux too.
If they happen to use SSE instructions they will crash if incoming stack
alignment is not 16-byte.

LLVM claims that 4-byte stack alignment is the standard, and it only aligns to
4-byte, hence the crash. Apparently older versions of GCC/glibc would crash
if it set alignment to 16-byte.

But since the oldest GCC we support is 4.1.2, and disable LLVM on anything older
just set stack alignment to 16-byte for all functions. LLVM will realign stack
as needed. To be safe turn this on only on Linux.

This should really be fixed by either GCC or LLVM, but until that happens (see
LLVM PR8152) lets use this workaround.
0.96
Török Edvin 16 years ago
parent 93e0033fb2
commit 3eef86ee9f
  1. 4
      ChangeLog
  2. 4
      libclamav/c++/bytecode2llvm.cpp

@ -1,3 +1,7 @@
Wed Sep 15 13:19:12 EEST 2010 (edwin)
-------------------------------------
* libclamav/c++/bytecode2llvm.cpp: workaround crash due to gcc stack alignment requirements (bb #2270)
Fri Sep 10 22:10:33 EEST 2010 (edwin)
-------------------------------------
* libclamav/pdf.c, pe.c, bytecode*: Fix bytecode virusname reporting (bb #2255)

@ -908,6 +908,10 @@ public:
BytecodeID+"f"+Twine(j), M);
Functions[j]->setDoesNotThrow();
Functions[j]->setCallingConv(CallingConv::Fast);
#ifdef C_LINUX
/* bb #2270, this should really be fixed either by LLVM or GCC.*/
Functions[j]->addFnAttr(Attribute::constructStackAlignmentFromInt(16));
#endif
}
const Type *I32Ty = Type::getInt32Ty(Context);
PM.add(createDeadCodeEliminationPass());

Loading…
Cancel
Save