From 4fc0a32572cd6d74037bc8318e12fd1e69df9683 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Tue, 13 Jun 2006 18:55:26 -0700 Subject: [PATCH] Do not brev() strings in stub for PackLinuxEl32armBe. --- src/Makefile | 3 ++- src/p_lx_elf.cpp | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index e992e6ba..6d746c2e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,7 +18,8 @@ ifeq ($(CXX),) CXX = g++ endif ifeq ($(CXX),g++) -CXXFLAGS += -O2 -MMD +#CXXFLAGS += -O2 -MMD +CXXFLAGS += -g -MMD CXXFLAGS += -Wall -W -Wcast-align -Wcast-qual -Wpointer-arith -Wwrite-strings -Werror endif CPPFLAGS += $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index b29fc3e8..3fa33076 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -611,7 +611,24 @@ PackLinuxElf32armBe::buildLoader(const Filter *ft) // FIXME unsigned const sz_fold = sizeof(linux_elf32arm_fold); MemBuffer brev_loader(sz_loader); MemBuffer brev_fold (sz_fold); - brev(brev_loader, linux_elf32arm_loader, sz_loader); + + // linux_elf32arm_loader[] is all instructions, except for two strings + // at the end: the copyright message, and the SELinux message. + // The copyright message begins and ends with '\n', and the SELinux + // message ends with '\n'. So copy back to the third '\n' from the end, + // and apply brev() only before that point. + int nl = 0; + int j; + for (j= sz_loader; --j>=0; ) { + unsigned char const c = linux_elf32arm_loader[j]; + brev_loader[j] = c; + if ('\n'==c) { + if (3==++nl) { + break; + } + } + } + brev(brev_loader, linux_elf32arm_loader, j); brev(brev_fold, linux_elf32arm_fold, sz_fold); ehdr_bele((Elf_BE32_Ehdr *)brev_fold.getVoidPtr(), (Elf_LE32_Ehdr const *)linux_elf32arm_fold); return buildLinuxLoader(brev_loader, sz_loader, brev_fold, sz_fold, ft);