sstrip: Was missing include of <byteswap.h>
[openwrt/staging/yousong.git] / tools / sstrip / src / sstrip.c
index 60c12c972c8ef2979beaac73486ce4d23ff763c0..9d5500dd31bb1246678c7341760585f7b66e348a 100644 (file)
 #include       <unistd.h>
 #include       <fcntl.h>
 #include       <elf.h>
-
-#ifdef __FreeBSD__
-/**
- * This seems to work on FreeBSD 5.3, should
- * work on all newer versions as well. I have
- * no idea if it will work on versions < 5.3
- *
- * Joe Estock (guru) <jestock at nutextonline.com>
- */
-#include <sys/endian.h>
-#define bswap_64 __bswap64
-#define bswap_32 __bswap32
-#define bswap_16 __bswap16
-#elif defined(__APPLE__)
-#include       <machine/endian.h>
-#include       <machine/byte_order.h>
-#define __BYTE_ORDER BYTE_ORDER
-#define __BIG_ENDIAN BIG_ENDIAN
-#define bswap_16(x) NXSwapShort(x)
-#define bswap_32(x) NXSwapInt(x)
-#define bswap_64(x) NXSwapLongLong(x)
-#else
-#include       <endian.h>
 #include       <byteswap.h>
-#endif 
-
 
 #ifndef TRUE
 #define        TRUE            1
@@ -277,8 +252,7 @@ static int modifyheaders ## CLASS (Elf ## CLASS ## _Ehdr *ehdr, \
                        ESET(phdr->p_offset,newsize); \
                        ESET(phdr->p_filesz,0); \
                } else if (EGET(phdr->p_offset) + EGET(phdr->p_filesz) > newsize) { \
-                       newsize -= EGET(phdr->p_offset); \
-                       ESET(phdr->p_filesz, newsize); \
+                       ESET(phdr->p_filesz, newsize - EGET(phdr->p_offset)); \
                } \
        } \
  \