diff --git a/src/stub/l_lx_elf.c b/src/stub/l_lx_elf.c index b86a95d9..d2a6ec66 100644 --- a/src/stub/l_lx_elf.c +++ b/src/stub/l_lx_elf.c @@ -328,8 +328,7 @@ void *upx_main( Elf32_Phdr const *phdr = (Elf32_Phdr const *)(1+ehdr); Elf32_Addr entry; struct Extent xo; - struct Extent xi = { 0, (sizeof(struct p_info) + lsize + (char *)my_ehdr) }; - // warning: 'const' cast away + struct Extent xi = { 0, sizeof(struct p_info) + lsize + CONST_CAST(char *, my_ehdr) }; size_t const sz_elfhdrs = ((size_t *)xi.buf)[0]; // sizeof(Ehdr+Phdrs), uncompressed size_t const sz_pckhdrs = ((size_t *)xi.buf)[1]; // sizeof(Ehdr+Phdrs), compressed diff --git a/src/stub/l_lx_sh.c b/src/stub/l_lx_sh.c index d1fa3d47..1b5d9f7c 100644 --- a/src/stub/l_lx_sh.c +++ b/src/stub/l_lx_sh.c @@ -296,7 +296,7 @@ void *upx_main( *(unsigned short const *)(0x7c + (char const *)my_ehdr); struct Extent xi = { // describe compressed shell script ((Elf32_Phdr const *)(1 + my_ehdr))->p_filesz - lsize, - (lsize + (char *)my_ehdr) // warning: 'const' cast away + lsize + CONST_CAST(char *, my_ehdr) }; struct Extent xo = { ((struct p_info *)xi.buf)[-1].p_filesize, uncbuf }; diff --git a/src/stub/linux.hh b/src/stub/linux.hh index 43f546c6..661d49bd 100644 --- a/src/stub/linux.hh +++ b/src/stub/linux.hh @@ -51,6 +51,10 @@ struct timex; #include +#define CONST_CAST(type, var) \ + ((type) ((unsigned long) (var))) + + /************************************************************************* // constants and types **************************************************************************/