Merge Mainline
This commit is contained in:
commit
0f7e04b681
@ -173,6 +173,14 @@ menu "Global build settings"
|
||||
help
|
||||
Specifies arguments passed to the strip command when stripping binaries.
|
||||
|
||||
config SSTRIP_ARGS
|
||||
string
|
||||
prompt "Sstrip arguments"
|
||||
depends on USE_SSTRIP
|
||||
default "-z"
|
||||
help
|
||||
Specifies arguments passed to the sstrip command when stripping binaries.
|
||||
|
||||
config STRIP_KERNEL_EXPORTS
|
||||
bool "Strip unnecessary exports from the kernel image"
|
||||
help
|
||||
@ -272,11 +280,11 @@ menu "Global build settings"
|
||||
bool "Strong"
|
||||
endchoice
|
||||
|
||||
config KERNEL_STACKPROTECTOR
|
||||
config KERNEL_STACKPROTECTOR
|
||||
bool
|
||||
default KERNEL_CC_STACKPROTECTOR_REGULAR || KERNEL_CC_STACKPROTECTOR_STRONG
|
||||
|
||||
config KERNEL_STACKPROTECTOR_STRONG
|
||||
config KERNEL_STACKPROTECTOR_STRONG
|
||||
bool
|
||||
default KERNEL_CC_STACKPROTECTOR_STRONG
|
||||
|
||||
|
||||
@ -100,6 +100,11 @@ menuconfig DEVEL
|
||||
It can be a git hash or a branch name.
|
||||
If unused, the clone's repository HEAD will be checked-out.
|
||||
|
||||
config KERNEL_GIT_MIRROR_HASH
|
||||
string "Enter hash of Git kernel tree source checkout tarball" if DEVEL
|
||||
depends on (KERNEL_GIT_CLONE_URI != "")
|
||||
default ""
|
||||
|
||||
config BUILD_LOG
|
||||
bool "Enable log files during build process" if DEVEL
|
||||
help
|
||||
|
||||
@ -86,6 +86,8 @@ define Host/Configure/Default
|
||||
LDFLAGS="$(HOST_LDFLAGS)" \
|
||||
cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_C_COMPILER="$(HOSTCC)" \
|
||||
-DCMAKE_CXX_COMPILER="$(HOSTCXX)" \
|
||||
-DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
|
||||
-DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
|
||||
-DCMAKE_EXE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
|
||||
|
||||
@ -184,6 +184,8 @@ ifndef DUMP
|
||||
clean-build: host-clean-build
|
||||
endif
|
||||
|
||||
$(DL_DIR)/$(FILE): FORCE
|
||||
|
||||
$(_host_target)host-prepare: $(HOST_STAMP_PREPARED)
|
||||
$(_host_target)host-configure: $(HOST_STAMP_CONFIGURED)
|
||||
$(_host_target)host-compile: $(HOST_STAMP_BUILT) $(HOST_STAMP_INSTALLED)
|
||||
|
||||
@ -218,8 +218,8 @@ $(_endef)
|
||||
ifneq ($$(CONFIG_IPK_FILES_CHECKSUMS),)
|
||||
(cd $$(IDIR_$(1)); \
|
||||
( \
|
||||
find . -type f \! -path ./CONTROL/\* -exec sha256sum \{\} \; 2> /dev/null | \
|
||||
sed 's|\([[:blank:]]\)\./|\1/|' > $$(IDIR_$(1))/CONTROL/files-sha256sum \
|
||||
find . -type f \! -path ./CONTROL/\* -exec mkhash sha256 -n \{\} \; 2> /dev/null | \
|
||||
sed 's|\([[:blank:]]\)\./| \1/|' > $$(IDIR_$(1))/CONTROL/files-sha256sum \
|
||||
) || true \
|
||||
)
|
||||
endif
|
||||
|
||||
@ -187,6 +187,8 @@ define Build/CoreTargets
|
||||
$(call Build/Autoclean)
|
||||
$(call DefaultTargets)
|
||||
|
||||
$(DL_DIR)/$(FILE): FORCE
|
||||
|
||||
download:
|
||||
$(foreach hook,$(Hooks/Download),
|
||||
$(call $(hook))$(sep)
|
||||
|
||||
@ -149,6 +149,7 @@ $(eval $(call SetupHostCommand,perl,Please install Perl 5.x, \
|
||||
$(eval $(call CleanupPython2))
|
||||
|
||||
$(eval $(call SetupHostCommand,python,Please install Python >= 3.5, \
|
||||
python3.9 -V 2>&1 | grep 'Python 3', \
|
||||
python3.8 -V 2>&1 | grep 'Python 3', \
|
||||
python3.7 -V 2>&1 | grep 'Python 3', \
|
||||
python3.6 -V 2>&1 | grep 'Python 3', \
|
||||
@ -156,6 +157,7 @@ $(eval $(call SetupHostCommand,python,Please install Python >= 3.5, \
|
||||
python3 -V 2>&1 | grep -E 'Python 3\.[5-9]\.?'))
|
||||
|
||||
$(eval $(call SetupHostCommand,python3,Please install Python >= 3.5, \
|
||||
python3.9 -V 2>&1 | grep 'Python 3', \
|
||||
python3.8 -V 2>&1 | grep 'Python 3', \
|
||||
python3.7 -V 2>&1 | grep 'Python 3', \
|
||||
python3.6 -V 2>&1 | grep 'Python 3', \
|
||||
|
||||
@ -23,7 +23,7 @@ define subtarget
|
||||
endef
|
||||
|
||||
define ERROR
|
||||
($(call MESSAGE, $(2)); $(if $(BUILD_LOG), echo "$(2)" >> $(BUILD_LOG_DIR)/$(1)/error.txt))
|
||||
($(call MESSAGE, $(2)); $(if $(BUILD_LOG), echo "$(2)" >> $(BUILD_LOG_DIR)/$(1)/error.txt;) $(if $(3),, exit 1;))
|
||||
endef
|
||||
|
||||
lastdir=$(word $(words $(subst /, ,$(1))),$(subst /, ,$(1)))
|
||||
@ -66,7 +66,7 @@ define subdir
|
||||
$(foreach btype,$(buildtypes-$(bd)),
|
||||
$(call warn_eval,$(1)/$(bd),t,T,$(1)/$(bd)/$(btype)/$(target): $(if $(NO_DEPS)$(QUILT),,$($(1)/$(bd)/$(btype)/$(target)) $(call $(1)//$(btype)/$(target),$(1)/$(bd)/$(btype))))
|
||||
$(call log_make,$(1)/$(bd),$(target),$(btype),$(filter-out __default,$(variant))) \
|
||||
$(if $(findstring $(bd),$($(1)/builddirs-ignore-$(btype)-$(target))), || $(call ERROR,$(1), ERROR: $(1)/$(bd) [$(btype)] failed to build.))
|
||||
|| $(call ERROR,$(2), ERROR: $(1)/$(bd) [$(btype)] failed to build.,$(findstring $(bd),$($(1)/builddirs-ignore-$(btype)-$(target))))
|
||||
$(if $(call diralias,$(bd)),$(call warn_eval,$(1)/$(bd),l,T,$(1)/$(call diralias,$(bd))/$(btype)/$(target): $(1)/$(bd)/$(btype)/$(target)))
|
||||
)
|
||||
$(call warn_eval,$(1)/$(bd),t,T,$(1)/$(bd)/$(target): $(if $(NO_DEPS)$(QUILT),,$($(1)/$(bd)/$(target)) $(call $(1)//$(target),$(1)/$(bd))))
|
||||
@ -74,7 +74,7 @@ define subdir
|
||||
$(if $(BUILD_LOG),@mkdir -p $(BUILD_LOG_DIR)/$(1)/$(bd)/$(filter-out __default,$(variant)))
|
||||
$(if $($(1)/autoremove),$(call rebuild_check,$(1)/$(bd),$(target),,$(filter-out __default,$(variant))))
|
||||
$(call log_make,$(1)/$(bd),$(target),,$(filter-out __default,$(variant))) \
|
||||
$(if $(findstring $(bd),$($(1)/builddirs-ignore-$(target))), || $(call ERROR,$(1), ERROR: $(1)/$(bd) failed to build$(if $(filter-out __default,$(variant)), (build variant: $(variant))).))
|
||||
|| $(call ERROR,$(1), ERROR: $(1)/$(bd) failed to build$(if $(filter-out __default,$(variant)), (build variant: $(variant))).,$(findstring $(bd),$($(1)/builddirs-ignore-$(target))))
|
||||
)
|
||||
$(if $(PREREQ_ONLY)$(DUMP_TARGET_DB),,
|
||||
# aliases
|
||||
|
||||
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=linux-firmware
|
||||
PKG_VERSION:=20201118
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE_URL:=@KERNEL/linux/kernel/firmware
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
|
||||
@ -101,9 +101,7 @@ Package/brcmfmac-firmware-43455-sdio-rpi-4b = $(call Package/firmware-default,Br
|
||||
define Package/brcmfmac-firmware-43455-sdio-rpi-4b/install
|
||||
$(INSTALL_DIR) $(1)/lib/firmware/brcm
|
||||
$(INSTALL_DATA) \
|
||||
$(PKG_BUILD_DIR)/brcm/brcmfmac43455-sdio.raspberrypi,3-model-b-plus.txt \
|
||||
$(1)/lib/firmware/brcm/brcmfmac43455-sdio.raspberrypi,4-model-b.txt
|
||||
$(SED) 's/boardflags3=.*/boardflags3=0x44200100/g' \
|
||||
$(PKG_BUILD_DIR)/brcm/brcmfmac43455-sdio.raspberrypi,4-model-b.txt \
|
||||
$(1)/lib/firmware/brcm/brcmfmac43455-sdio.raspberrypi,4-model-b.txt
|
||||
endef
|
||||
$(eval $(call BuildPackage,brcmfmac-firmware-43455-sdio-rpi-4b))
|
||||
|
||||
@ -13,23 +13,22 @@ PKG_RELEASE:=1
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/namjaejeon/linux-exfat-oot/tar.gz/$(PKG_VERSION)?
|
||||
PKG_HASH:=0ff77dd7d39eb231d00c3c4909b9fad31ebeeb618bd6fa18fce142becc9c1f98
|
||||
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-exfat-oot-$(PKG_VERSION)
|
||||
|
||||
PKG_MAINTAINER:=
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
TAR_OPTIONS+= --strip-components 1
|
||||
TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
|
||||
|
||||
define KernelPackage/fs-exfat
|
||||
SECTION:=kernel
|
||||
CATEGORY:=Kernel modules
|
||||
SUBMENU:=Filesystems
|
||||
TITLE:=exFAT kernel module
|
||||
URL:=https://github.com/namjaejeon/linux-exfat-oot
|
||||
FILES:=$(PKG_BUILD_DIR)/exfat.ko
|
||||
AUTOLOAD:=$(call AutoProbe,exfat)
|
||||
DEPENDS:=+kmod-nls-base
|
||||
DEPENDS:= +kmod-nls-base
|
||||
endef
|
||||
|
||||
define KernelPackage/exfat/description
|
||||
|
||||
@ -1,72 +0,0 @@
|
||||
# Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC)
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=coremark
|
||||
PKG_RELEASE:=15
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/eembc/coremark.git
|
||||
PKG_SOURCE_VERSION:=7685fd32bd7919581bfff2881a6dac6320581400
|
||||
PKG_SOURCE_DATE:=2020-05-28
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/coremark
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=CoreMark Embedded Microprocessor Benchmark
|
||||
URL:=https://github.com/eembc/coremark
|
||||
endef
|
||||
|
||||
define Package/coremark/description
|
||||
Embedded Microprocessor Benchmark
|
||||
endef
|
||||
|
||||
DIR_ARCH:=linux
|
||||
|
||||
ifeq ($(CONFIG_ARCH_64BIT),y)
|
||||
DIR_ARCH:=linux64
|
||||
else ifeq ($(CONFIG_64BIT),y)
|
||||
DIR_ARCH:=linux64
|
||||
endif
|
||||
|
||||
TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3 -flto
|
||||
|
||||
define Build/Compile
|
||||
$(SED) 's|EXE = .exe|EXE =|' $(PKG_BUILD_DIR)/$(DIR_ARCH)/core_portme.mak
|
||||
mkdir $(PKG_BUILD_DIR)/$(ARCH)
|
||||
cp -r $(PKG_BUILD_DIR)/$(DIR_ARCH)/* $(PKG_BUILD_DIR)/$(ARCH)
|
||||
$(MAKE) XCFLAGS="-DMULTITHREAD=16 -DUSE_PTHREAD" -C $(PKG_BUILD_DIR) PORT_DIR=$(ARCH) $(MAKE_FLAGS) \
|
||||
compile
|
||||
endef
|
||||
|
||||
define Package/coremark/install
|
||||
$(INSTALL_DIR) $(1)/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/coremark $(1)/bin/
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(INSTALL_BIN) ./coremark.sh $(1)/etc/
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./coremark $(1)/etc/uci-defaults/xxx-coremark
|
||||
endef
|
||||
|
||||
define Package/coremark/postinst
|
||||
#!/bin/sh
|
||||
[ -n "$${IPKG_INSTROOT}" ] || sed -i '/coremark/d' /etc/crontabs/root
|
||||
[ -n "$${IPKG_INSTROOT}" ] || echo "0 4 * * * /etc/coremark.sh" >> /etc/crontabs/root
|
||||
[ -n "$${IPKG_INSTROOT}" ] || crontab /etc/crontabs/root
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,coremark))
|
||||
@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
sed -i '/coremark/d' /etc/crontabs/root
|
||||
echo "0 4 * * * /etc/coremark.sh" >> /etc/crontabs/root
|
||||
crontab /etc/crontabs/root
|
||||
|
||||
touch /etc/bench.log
|
||||
@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
/bin/coremark > /tmp/coremark.log
|
||||
|
||||
cat /tmp/coremark.log | grep "CoreMark 1.0" | cut -d "/" -f 1 > /etc/bench.log
|
||||
sed -i 's/CoreMark 1.0/(CpuMark/g' /etc/bench.log
|
||||
echo " Scores)" >> /etc/bench.log
|
||||
|
||||
if [ -f "/etc/bench.log" ]; then
|
||||
sed -i '/coremark/d' /etc/crontabs/root
|
||||
crontab /etc/crontabs/root
|
||||
fi
|
||||
@ -8,12 +8,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=kcptun
|
||||
PKG_VERSION:=20201010
|
||||
PKG_VERSION:=20201126
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/xtaci/kcptun/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=afab2a087b787e59e129c7d4fbc578e1131d264c0da1ce23cd1282321fc3c189
|
||||
PKG_HASH:=cb4cc62fe6a9f3452f20ada676996b48039f091bdae25943955ac9e2299a9c09
|
||||
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_LICENSE_FILES:=LICENSE.md
|
||||
|
||||
@ -8,16 +8,16 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libiconv-full
|
||||
PKG_VERSION:=1.11.1
|
||||
PKG_RELEASE:=4
|
||||
|
||||
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
|
||||
PKG_VERSION:=1.16
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=libiconv-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@GNU/libiconv
|
||||
PKG_HASH:=e78c347a1a0cb15f2648519e9799151f4b4a934b61ad9ee7424478efe2b8257f
|
||||
PKG_HASH:=e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/libiconv-$(PKG_VERSION)
|
||||
PKG_LICENSE:=LGPL-2.0
|
||||
|
||||
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
|
||||
PKG_LICENSE:=LGPL-2.1-or-later
|
||||
PKG_LICENSE_FILES:=COPYING.LIB
|
||||
|
||||
PKG_FIXUP:=patch-libtool
|
||||
@ -25,7 +25,7 @@ PKG_FIXUP:=patch-libtool
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/libiconv-full/Default
|
||||
URL:=http://www.gnu.org/software/libiconv/
|
||||
URL:=https://www.gnu.org/software/libiconv/
|
||||
TITLE:=Character set conversion
|
||||
endef
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,31 +0,0 @@
|
||||
--- /dev/null
|
||||
+++ b/Makefile.am
|
||||
@@ -0,0 +1,2 @@
|
||||
+ACLOCAL_AMFLAGS = -I m4
|
||||
+SUBDIRS = .
|
||||
--- /dev/null
|
||||
+++ b/libcharset/Makefile.am
|
||||
@@ -0,0 +1 @@
|
||||
+ACLOCAL_AMFLAGS = -I m4
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -54,7 +54,7 @@ AC_ISC_POSIX
|
||||
|
||||
dnl checks for installer options
|
||||
|
||||
-AC_RELOCATABLE
|
||||
+gl_RELOCATABLE
|
||||
|
||||
AC_ARG_ENABLE([extra-encodings],
|
||||
[AC_HELP_STRING([--enable-extra-encodings],
|
||||
--- a/libcharset/configure.ac
|
||||
+++ b/libcharset/configure.ac
|
||||
@@ -41,7 +41,7 @@ AC_CANONICAL_HOST
|
||||
|
||||
dnl checks for installer options
|
||||
|
||||
-AC_RELOCATABLE_LIBRARY
|
||||
+gl_RELOCATABLE_LIBRARY
|
||||
|
||||
dnl checks for programs
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
Make iconv 1.11.x link correctly with libtool2 - argument "-Xcompiler" ensures "-shared" is passed to $(CC) when used as linker. Otherwise $(CC) tries to create an executable and fails while looking for a main()-function
|
||||
|
||||
diff -ruN libiconv-1.11.1/lib/Makefile.in libiconv-1.11.1.mod/lib/Makefile.in
|
||||
--- libiconv-1.11.1/lib/Makefile.in 2006-07-14 15:18:42.000000000 +0200
|
||||
+++ libiconv-1.11.1.mod/lib/Makefile.in 2010-12-01 20:47:57.000000000 +0100
|
||||
@@ -70,9 +70,9 @@
|
||||
|
||||
preloadable_libiconv_linux.so : $(SOURCES)
|
||||
if test -n "@GCC@"; then \
|
||||
- $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(DEFS) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -shared -o preloadable_libiconv_linux.so; \
|
||||
+ $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(DEFS) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -Xcompiler -shared -o preloadable_libiconv_linux.so; \
|
||||
else \
|
||||
- $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(DEFS) -KPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -shared -o preloadable_libiconv_linux.so; \
|
||||
+ $(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(DEFS) -KPIC -DPIC -DLIBICONV_PLUG $(SOURCES) -Xcompiler -shared -o preloadable_libiconv_linux.so; \
|
||||
fi
|
||||
|
||||
preloadable_libiconv_solaris.so : $(SOURCES)
|
||||
@ -1,23 +0,0 @@
|
||||
--- a/m4/canonicalize.m4
|
||||
+++ b/m4/canonicalize.m4
|
||||
@@ -11,8 +11,6 @@ AC_DEFUN([gl_CANONICALIZE],
|
||||
AC_CHECK_FUNCS(canonicalize_file_name)
|
||||
if test $ac_cv_func_canonicalize_file_name = no; then
|
||||
AC_LIBOBJ(canonicalize)
|
||||
- AC_DEFINE([realpath], [rpl_realpath],
|
||||
- [Define to a replacement function name for realpath().])
|
||||
gl_PREREQ_CANONICALIZE
|
||||
fi
|
||||
])
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -35532,9 +35532,6 @@ done
|
||||
if test $ac_cv_func_canonicalize_file_name = no; then
|
||||
SRCLIBOBJS="$SRCLIBOBJS canonicalize.$ac_objext"
|
||||
|
||||
-cat >>confdefs.h <<\_ACEOF
|
||||
-#define realpath rpl_realpath
|
||||
-_ACEOF
|
||||
|
||||
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2014 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libroxml
|
||||
PKG_VERSION:=3.0.2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://download.libroxml.net/pool/v3.x
|
||||
PKG_HASH:=ed6d68d1bceabf98e5e76907411e2e4d93b2dbd48479ab41dede851f59dad6a3
|
||||
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_LICENSE:=LGPL-2.1+
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/libroxml
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=Minimum, easy-to-use, C implementation for xml file parsing
|
||||
URL:=http://www.libroxml.net/
|
||||
ABI_VERSION:=3.0.2
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-shared \
|
||||
--enable-static \
|
||||
--disable-roxml
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)
|
||||
$(CP) $(PKG_INSTALL_DIR)/* $(1)/
|
||||
endef
|
||||
|
||||
define Package/libroxml/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libroxml.so.* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libroxml))
|
||||
@ -1,54 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2010-2015 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libusb-compat
|
||||
PKG_VERSION:=0.1.5
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:=@SF/libusb
|
||||
PKG_HASH:=404ef4b6b324be79ac1bfb3d839eac860fbc929e6acb1ef88793a6ea328bc55a
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_LICENSE:=LGPL-2.1
|
||||
|
||||
PKG_MAINTAINER := Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/libusb-compat
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=libusb-0.1 compatibility library
|
||||
DEPENDS:=+libusb-1.0
|
||||
URL:=http://libusb.wiki.sourceforge.net/
|
||||
ABI_VERSION:=4
|
||||
endef
|
||||
|
||||
define Package/libusb-compat/description
|
||||
libusb is a C library that gives applications easy access to USB devices on
|
||||
many different operating systems.
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += $(FPIC)
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)
|
||||
$(CP) $(PKG_INSTALL_DIR)/* $(1)/
|
||||
$(INSTALL_DIR) $(2)/bin
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/bin/libusb-config $(2)/bin/
|
||||
endef
|
||||
|
||||
define Package/libusb-compat/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libusb-0.1.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libusb-compat))
|
||||
@ -1,185 +0,0 @@
|
||||
--- a/libusb/usb.h
|
||||
+++ b/libusb/usb.h
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
+#include <stdint.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <dirent.h>
|
||||
@@ -78,40 +79,40 @@
|
||||
|
||||
/* All standard descriptors have these 2 fields in common */
|
||||
struct usb_descriptor_header {
|
||||
- u_int8_t bLength;
|
||||
- u_int8_t bDescriptorType;
|
||||
+ uint8_t bLength;
|
||||
+ uint8_t bDescriptorType;
|
||||
};
|
||||
|
||||
/* String descriptor */
|
||||
struct usb_string_descriptor {
|
||||
- u_int8_t bLength;
|
||||
- u_int8_t bDescriptorType;
|
||||
- u_int16_t wData[1];
|
||||
+ uint8_t bLength;
|
||||
+ uint8_t bDescriptorType;
|
||||
+ uint16_t wData[1];
|
||||
};
|
||||
|
||||
/* HID descriptor */
|
||||
struct usb_hid_descriptor {
|
||||
- u_int8_t bLength;
|
||||
- u_int8_t bDescriptorType;
|
||||
- u_int16_t bcdHID;
|
||||
- u_int8_t bCountryCode;
|
||||
- u_int8_t bNumDescriptors;
|
||||
- /* u_int8_t bReportDescriptorType; */
|
||||
- /* u_int16_t wDescriptorLength; */
|
||||
+ uint8_t bLength;
|
||||
+ uint8_t bDescriptorType;
|
||||
+ uint16_t bcdHID;
|
||||
+ uint8_t bCountryCode;
|
||||
+ uint8_t bNumDescriptors;
|
||||
+ /* uint8_t bReportDescriptorType; */
|
||||
+ /* uint16_t wDescriptorLength; */
|
||||
/* ... */
|
||||
};
|
||||
|
||||
/* Endpoint descriptor */
|
||||
#define USB_MAXENDPOINTS 32
|
||||
struct usb_endpoint_descriptor {
|
||||
- u_int8_t bLength;
|
||||
- u_int8_t bDescriptorType;
|
||||
- u_int8_t bEndpointAddress;
|
||||
- u_int8_t bmAttributes;
|
||||
- u_int16_t wMaxPacketSize;
|
||||
- u_int8_t bInterval;
|
||||
- u_int8_t bRefresh;
|
||||
- u_int8_t bSynchAddress;
|
||||
+ uint8_t bLength;
|
||||
+ uint8_t bDescriptorType;
|
||||
+ uint8_t bEndpointAddress;
|
||||
+ uint8_t bmAttributes;
|
||||
+ uint16_t wMaxPacketSize;
|
||||
+ uint8_t bInterval;
|
||||
+ uint8_t bRefresh;
|
||||
+ uint8_t bSynchAddress;
|
||||
|
||||
unsigned char *extra; /* Extra descriptors */
|
||||
int extralen;
|
||||
@@ -129,15 +130,15 @@ struct usb_endpoint_descriptor {
|
||||
/* Interface descriptor */
|
||||
#define USB_MAXINTERFACES 32
|
||||
struct usb_interface_descriptor {
|
||||
- u_int8_t bLength;
|
||||
- u_int8_t bDescriptorType;
|
||||
- u_int8_t bInterfaceNumber;
|
||||
- u_int8_t bAlternateSetting;
|
||||
- u_int8_t bNumEndpoints;
|
||||
- u_int8_t bInterfaceClass;
|
||||
- u_int8_t bInterfaceSubClass;
|
||||
- u_int8_t bInterfaceProtocol;
|
||||
- u_int8_t iInterface;
|
||||
+ uint8_t bLength;
|
||||
+ uint8_t bDescriptorType;
|
||||
+ uint8_t bInterfaceNumber;
|
||||
+ uint8_t bAlternateSetting;
|
||||
+ uint8_t bNumEndpoints;
|
||||
+ uint8_t bInterfaceClass;
|
||||
+ uint8_t bInterfaceSubClass;
|
||||
+ uint8_t bInterfaceProtocol;
|
||||
+ uint8_t iInterface;
|
||||
|
||||
struct usb_endpoint_descriptor *endpoint;
|
||||
|
||||
@@ -155,14 +156,14 @@ struct usb_interface {
|
||||
/* Configuration descriptor information.. */
|
||||
#define USB_MAXCONFIG 8
|
||||
struct usb_config_descriptor {
|
||||
- u_int8_t bLength;
|
||||
- u_int8_t bDescriptorType;
|
||||
- u_int16_t wTotalLength;
|
||||
- u_int8_t bNumInterfaces;
|
||||
- u_int8_t bConfigurationValue;
|
||||
- u_int8_t iConfiguration;
|
||||
- u_int8_t bmAttributes;
|
||||
- u_int8_t MaxPower;
|
||||
+ uint8_t bLength;
|
||||
+ uint8_t bDescriptorType;
|
||||
+ uint16_t wTotalLength;
|
||||
+ uint8_t bNumInterfaces;
|
||||
+ uint8_t bConfigurationValue;
|
||||
+ uint8_t iConfiguration;
|
||||
+ uint8_t bmAttributes;
|
||||
+ uint8_t MaxPower;
|
||||
|
||||
struct usb_interface *interface;
|
||||
|
||||
@@ -172,28 +173,28 @@ struct usb_config_descriptor {
|
||||
|
||||
/* Device descriptor */
|
||||
struct usb_device_descriptor {
|
||||
- u_int8_t bLength;
|
||||
- u_int8_t bDescriptorType;
|
||||
- u_int16_t bcdUSB;
|
||||
- u_int8_t bDeviceClass;
|
||||
- u_int8_t bDeviceSubClass;
|
||||
- u_int8_t bDeviceProtocol;
|
||||
- u_int8_t bMaxPacketSize0;
|
||||
- u_int16_t idVendor;
|
||||
- u_int16_t idProduct;
|
||||
- u_int16_t bcdDevice;
|
||||
- u_int8_t iManufacturer;
|
||||
- u_int8_t iProduct;
|
||||
- u_int8_t iSerialNumber;
|
||||
- u_int8_t bNumConfigurations;
|
||||
+ uint8_t bLength;
|
||||
+ uint8_t bDescriptorType;
|
||||
+ uint16_t bcdUSB;
|
||||
+ uint8_t bDeviceClass;
|
||||
+ uint8_t bDeviceSubClass;
|
||||
+ uint8_t bDeviceProtocol;
|
||||
+ uint8_t bMaxPacketSize0;
|
||||
+ uint16_t idVendor;
|
||||
+ uint16_t idProduct;
|
||||
+ uint16_t bcdDevice;
|
||||
+ uint8_t iManufacturer;
|
||||
+ uint8_t iProduct;
|
||||
+ uint8_t iSerialNumber;
|
||||
+ uint8_t bNumConfigurations;
|
||||
};
|
||||
|
||||
struct usb_ctrl_setup {
|
||||
- u_int8_t bRequestType;
|
||||
- u_int8_t bRequest;
|
||||
- u_int16_t wValue;
|
||||
- u_int16_t wIndex;
|
||||
- u_int16_t wLength;
|
||||
+ uint8_t bRequestType;
|
||||
+ uint8_t bRequest;
|
||||
+ uint16_t wValue;
|
||||
+ uint16_t wIndex;
|
||||
+ uint16_t wLength;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -254,7 +255,7 @@ struct usb_device {
|
||||
|
||||
void *dev; /* Darwin support */
|
||||
|
||||
- u_int8_t devnum;
|
||||
+ uint8_t devnum;
|
||||
|
||||
unsigned char num_children;
|
||||
struct usb_device **children;
|
||||
@@ -266,7 +267,7 @@ struct usb_bus {
|
||||
char dirname[PATH_MAX + 1];
|
||||
|
||||
struct usb_device *devices;
|
||||
- u_int32_t location;
|
||||
+ uint32_t location;
|
||||
|
||||
struct usb_device *root_dev;
|
||||
};
|
||||
34
package/libs/nettle/patches/100-portability.patch
Normal file
34
package/libs/nettle/patches/100-portability.patch
Normal file
@ -0,0 +1,34 @@
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -4635,6 +4635,7 @@ $as_echo_n "checking build system compil
|
||||
# remove anything that might look like compiler output to our "||" expression
|
||||
rm -f conftest* a.out b.out a.exe a_out.exe
|
||||
cat >conftest.c <<EOF
|
||||
+#include <stdlib.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
@@ -4667,6 +4668,7 @@ $as_echo_n "checking build system compil
|
||||
# remove anything that might look like compiler output to our "||" expression
|
||||
rm -f conftest* a.out b.out a.exe a_out.exe
|
||||
cat >conftest.c <<EOF
|
||||
+#include <stdlib.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
@@ -4703,6 +4705,7 @@ $as_echo_n "checking build system compil
|
||||
# remove anything that might look like compiler output to our "||" expression
|
||||
rm -f conftest* a.out b.out a.exe a_out.exe
|
||||
cat >conftest.c <<EOF
|
||||
+#include <stdlib.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
@@ -4753,6 +4756,7 @@ else
|
||||
gmp_cv_prog_exeext_for_build="$EXEEXT"
|
||||
else
|
||||
cat >conftest.c <<EOF
|
||||
+#include <stdlib.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
@ -8,12 +8,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=lldpd
|
||||
PKG_VERSION:=1.0.5
|
||||
PKG_RELEASE:=2
|
||||
PKG_VERSION:=1.0.7
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://media.luffy.cx/files/lldpd
|
||||
PKG_HASH:=2dd3b212f4dbabfcbb2794c0010b245f9f8e74b387984e757be6243a74c6cb99
|
||||
PKG_HASH:=1df79179d489c841b49265f2ab5ff05f284a647e95862d2f3c02b3fb079a87e1
|
||||
|
||||
PKG_MAINTAINER:=Stijn Tintel <stijn@linux-ipv6.be>
|
||||
PKG_LICENSE:=ISC
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=umdns
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE_URL=$(PROJECT_GIT)/project/mdnsd.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
"whitelist": [
|
||||
"read",
|
||||
"write",
|
||||
"writev",
|
||||
"open",
|
||||
"close",
|
||||
"time",
|
||||
|
||||
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=tcpdump
|
||||
PKG_VERSION:=4.9.3
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://www.us.tcpdump.org/release/ \
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
--- a/print-ppp.c
|
||||
+++ b/print-ppp.c
|
||||
@@ -1368,19 +1368,29 @@ trunc:
|
||||
}
|
||||
|
||||
#ifndef TCPDUMP_MINI
|
||||
+/*
|
||||
+ * Un-escape RFC 1662 PPP in HDLC-like framing, with octet escapes.
|
||||
+ * The length argument is the on-the-wire length, not the captured
|
||||
+ * length; we can only un-escape the captured part.
|
||||
+ */
|
||||
static void
|
||||
ppp_hdlc(netdissect_options *ndo,
|
||||
const u_char *p, int length)
|
||||
{
|
||||
+ u_int caplen = ndo->ndo_snapend - p;
|
||||
u_char *b, *t, c;
|
||||
const u_char *s;
|
||||
- int i, proto;
|
||||
+ u_int i;
|
||||
+ int proto;
|
||||
const void *se;
|
||||
|
||||
+ if (caplen == 0)
|
||||
+ return;
|
||||
+
|
||||
if (length <= 0)
|
||||
return;
|
||||
|
||||
- b = (u_char *)malloc(length);
|
||||
+ b = (u_char *)malloc(caplen);
|
||||
if (b == NULL)
|
||||
return;
|
||||
|
||||
@@ -1389,10 +1399,10 @@ ppp_hdlc(netdissect_options *ndo,
|
||||
* Do this so that we dont overwrite the original packet
|
||||
* contents.
|
||||
*/
|
||||
- for (s = p, t = b, i = length; i > 0 && ND_TTEST(*s); i--) {
|
||||
+ for (s = p, t = b, i = caplen; i != 0; i--) {
|
||||
c = *s++;
|
||||
if (c == 0x7d) {
|
||||
- if (i <= 1 || !ND_TTEST(*s))
|
||||
+ if (i <= 1)
|
||||
break;
|
||||
i--;
|
||||
c = *s++ ^ 0x20;
|
||||
@ -9,14 +9,14 @@ include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=opkg
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=1
|
||||
PKG_FLAGS:=essential
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://git.openwrt.org/project/opkg-lede.git
|
||||
PKG_SOURCE_DATE:=2020-11-03
|
||||
PKG_SOURCE_VERSION:=da9746aaa28fdc63a6e062bf00b25eba52bc8e5f
|
||||
PKG_MIRROR_HASH:=9c42a8f7dbce4d50b01c3cd10e1974611ffdd9547c27f8f5725b6237433f54e2
|
||||
PKG_SOURCE_DATE:=2020-11-25
|
||||
PKG_SOURCE_VERSION:=66f458decf9fd2839d77bf420e93d9c78025488a
|
||||
PKG_MIRROR_HASH:=932cf0002fd05e8a231df6d3e2c807b2c62501aa36ac2a3e20665622872e262d
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
@ -1105,7 +1105,7 @@ config BUSYBOX_DEFAULT_FEATURE_FIND_MTIME
|
||||
default y
|
||||
config BUSYBOX_DEFAULT_FEATURE_FIND_MMIN
|
||||
bool
|
||||
default n
|
||||
default y
|
||||
config BUSYBOX_DEFAULT_FEATURE_FIND_PERM
|
||||
bool
|
||||
default y
|
||||
|
||||
4
rules.mk
4
rules.mk
@ -174,8 +174,6 @@ TARGET_CFLAGS:=$(TARGET_OPTIMIZATION)$(if $(CONFIG_DEBUG), -g3) $(call qstrip,$(
|
||||
TARGET_CXXFLAGS = $(TARGET_CFLAGS)
|
||||
TARGET_ASFLAGS_DEFAULT = $(TARGET_CFLAGS)
|
||||
TARGET_ASFLAGS = $(TARGET_ASFLAGS_DEFAULT)
|
||||
TARGET_CPPFLAGS:=-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include
|
||||
TARGET_LDFLAGS:=-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
|
||||
ifneq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
|
||||
LIBGCC_S_PATH=$(realpath $(wildcard $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC))))
|
||||
LIBGCC_S=$(if $(LIBGCC_S_PATH),-L$(dir $(LIBGCC_S_PATH)) -lgcc_s)
|
||||
@ -327,7 +325,7 @@ else
|
||||
STRIP:=$(TARGET_CROSS)strip $(call qstrip,$(CONFIG_STRIP_ARGS))
|
||||
else
|
||||
ifneq ($(CONFIG_USE_SSTRIP),)
|
||||
STRIP:=$(STAGING_DIR_HOST)/bin/sstrip
|
||||
STRIP:=$(STAGING_DIR_HOST)/bin/sstrip $(call qstrip,$(CONFIG_SSTRIP_ARGS))
|
||||
endif
|
||||
endif
|
||||
RSTRIP= \
|
||||
|
||||
@ -277,6 +277,24 @@ foreach my $mirror (@ARGV) {
|
||||
push @mirrors, 'https://sources.openwrt.org';
|
||||
push @mirrors, 'https://mirror2.openwrt.org/sources';
|
||||
|
||||
if (-f "$target/$filename") {
|
||||
$hash_cmd and do {
|
||||
if (system("cat '$target/$filename' | $hash_cmd > '$target/$filename.hash'")) {
|
||||
die "Failed to generate hash for $filename\n";
|
||||
}
|
||||
|
||||
my $sum = `cat "$target/$filename.hash"`;
|
||||
$sum =~ /^(\w+)\s*/ or die "Could not generate file hash\n";
|
||||
$sum = $1;
|
||||
|
||||
cleanup();
|
||||
exit 0 if $sum eq $file_hash;
|
||||
|
||||
die "Hash of the local file $filename does not match (file: $sum, requested: $file_hash) - deleting download.\n";
|
||||
unlink "$target/$filename";
|
||||
};
|
||||
}
|
||||
|
||||
while (!-f "$target/$filename") {
|
||||
my $mirror = shift @mirrors;
|
||||
$mirror or die "No more mirrors to try - giving up.\n";
|
||||
|
||||
@ -158,8 +158,8 @@ my %update_method = (
|
||||
'init' => "git clone --depth 1 '%s' '%s'",
|
||||
'init_branch' => "git clone --depth 1 --branch '%s' '%s' '%s'",
|
||||
'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
|
||||
'update' => "git pull --ff",
|
||||
'update_force' => "git pull --ff || (git reset --hard HEAD; git pull --ff; exit 1)",
|
||||
'update' => "git pull --ff-only",
|
||||
'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
|
||||
'post_update' => "git submodule update --init --recursive",
|
||||
'controldir' => ".git",
|
||||
'revision' => "git rev-parse --short HEAD | tr -d '\n'"},
|
||||
|
||||
@ -79,7 +79,12 @@
|
||||
|
||||
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
#include <endian.h>
|
||||
#else
|
||||
#include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
@ -89,6 +94,7 @@
|
||||
|
||||
#define ARRAY_SIZE(_n) (sizeof(_n) / sizeof((_n)[0]))
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
static void
|
||||
be32enc(void *buf, uint32_t u)
|
||||
{
|
||||
@ -99,6 +105,7 @@ be32enc(void *buf, uint32_t u)
|
||||
p[2] = ((uint8_t) ((u >> 8) & 0xff));
|
||||
p[3] = ((uint8_t) (u & 0xff));
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
be64enc(void *buf, uint64_t u)
|
||||
|
||||
151
scripts/size_compare.sh
Executable file
151
scripts/size_compare.sh
Executable file
@ -0,0 +1,151 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#
|
||||
# Copyright (C) 2020 Paul Spooren <mail@aparcar.org>
|
||||
#
|
||||
###
|
||||
### size_compare - compare size of OpenWrt packages against upstream
|
||||
###
|
||||
### The script compares locally compiled package with the package indexes
|
||||
### available upstream. This way the storage impact of optimizations or
|
||||
### feature modifiactions is easy to see.
|
||||
###
|
||||
### If no environmental variables are set the scritp reads the current
|
||||
### .config file. The evaluated env variables are the following:
|
||||
###
|
||||
### TARGET SUBTARGET ARCH PACKAGES BIN_DIR BASE_URL CHECK_INSTALLED
|
||||
###
|
||||
### Usage:
|
||||
### ./scripts/size_compare.sh
|
||||
###
|
||||
### Options:
|
||||
### -p --package-size Check IPK package size and not installed size
|
||||
### -h --help This message
|
||||
|
||||
CONFIG_TARGET=$(sed -n 's/^CONFIG_TARGET_BOARD="\(.*\)"$/\1/p' .config)
|
||||
CONFIG_SUBTARGET=$(sed -n 's/^CONFIG_TARGET_SUBTARGET="\(.*\)"$/\1/p' .config)
|
||||
CONFIG_ARCH=$(sed -n 's/^CONFIG_TARGET_ARCH_PACKAGES="\(.*\)"$/\1/p' .config)
|
||||
CONFIG_PACKAGES=$(sed -n 's/^CONFIG_PACKAGE_\(.*\)=y$/\1/p' .config | tr '\n' ' ')
|
||||
CONFIG_BIN_DIR=$(sed -n 's/^CONFIG_BINARY_DIR="\(.*\)"$/\1/p' .config)
|
||||
|
||||
TARGET=${TARGET:-$CONFIG_TARGET}
|
||||
SUBTARGET=${SUBTARGET:-$CONFIG_SUBTARGET}
|
||||
ARCH=${ARCH:-$CONFIG_ARCH}
|
||||
PACKAGES=${PACKAGES:-$CONFIG_PACKAGES}
|
||||
BIN_DIR=${CONFIG_BIN_DIR:-./bin}
|
||||
BASE_URL="${BASE_URL:-https://downloads.openwrt.org/snapshots}"
|
||||
CHECK_INSTALLED="${CHECK_INSTALLED:-y}"
|
||||
|
||||
TARGET_URL="$BASE_URL/targets/$TARGET/$SUBTARGET/packages/Packages.gz"
|
||||
CONFIG_URL="$BASE_URL/targets/$TARGET/$SUBTARGET/config.buildinfo"
|
||||
PACKAGES_URL="$BASE_URL/packages/$ARCH/base/Packages.gz"
|
||||
|
||||
if command -v curl > /dev/null; then
|
||||
DOWNLOAD_METHOD="curl"
|
||||
else
|
||||
DOWNLOAD_METHOD="wget --output-document=-"
|
||||
fi
|
||||
|
||||
help() {
|
||||
sed -rn 's/^### ?//;T;p' "$0"
|
||||
}
|
||||
|
||||
package_size () {
|
||||
FOUND_PACKAGE=
|
||||
if [ -z "$CHECK_INSTALLED" ]; then
|
||||
SEARCH_PATTERN="Size"
|
||||
else
|
||||
SEARCH_PATTERN="Installed-Size"
|
||||
fi
|
||||
while IFS= read -r line; do
|
||||
if [ "$line" = "Package: $2" ]; then
|
||||
FOUND_PACKAGE=y
|
||||
fi
|
||||
if [ -n "$FOUND_PACKAGE" ]; then
|
||||
case $line in
|
||||
"$SEARCH_PATTERN"*)
|
||||
echo "$line" | cut -d ' ' -f 2
|
||||
break
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done < "$1"
|
||||
}
|
||||
|
||||
compare_sizes () {
|
||||
for PACKAGE in $PACKAGES; do
|
||||
if [ "$PACKAGE" = "libc" ]; then
|
||||
continue
|
||||
fi
|
||||
PACKAGE_FILE=$(find "$BIN_DIR/packages/$ARCH/" \
|
||||
"$BIN_DIR/targets/$TARGET/$SUBTARGET/" \
|
||||
-name "${PACKAGE}_*.ipk" 2>/dev/null | head -n1)
|
||||
|
||||
if [ -z "$PACKAGE_FILE" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ -z "$CHECK_INSTALLED" ]; then
|
||||
SIZE_LOCAL=$(stat -c '%s' "$PACKAGE_FILE")
|
||||
else
|
||||
SIZE_LOCAL=$(tar tzvf "$PACKAGE_FILE" ./data.tar.gz | awk '{ print $3 }')
|
||||
fi
|
||||
SIZE_UPSTREAM=$(package_size "$TMP_INDEX" "$PACKAGE")
|
||||
SIZE_DIFF="$((SIZE_LOCAL-SIZE_UPSTREAM))"
|
||||
if [ "$SIZE_DIFF" -gt 0 ]; then
|
||||
SIZE_DIFF="+$SIZE_DIFF"
|
||||
fi
|
||||
if [ -n "$SIZE_UPSTREAM" ]; then
|
||||
echo "${SIZE_DIFF} ${SIZE_LOCAL} ${SIZE_UPSTREAM} $PACKAGE"
|
||||
else
|
||||
echo "$PACKAGE is missing upstream"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$1" = "-h" ]; then
|
||||
help
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "-p" ]; then
|
||||
CHECK_INSTALLED=
|
||||
fi
|
||||
|
||||
echo "Compare packages of $TARGET/$SUBTARGET/$ARCH":
|
||||
echo "$PACKAGES"
|
||||
echo
|
||||
|
||||
echo "Checking configuration difference"
|
||||
TMP_CONFIG=$(mktemp /tmp/config.XXXXXX)
|
||||
sed -n 's/^ \+config \(.*\)/\1/p' config/Config-build.in config/Config-devel.in > "${TMP_CONFIG}-FOCUS"
|
||||
sort .config | grep -f "${TMP_CONFIG}-FOCUS" | grep -v "^#" | sort > "${TMP_CONFIG}-LOCAL"
|
||||
mv .config .config.bak
|
||||
"$DOWNLOAD_METHOD" "$CONFIG_URL" > .config
|
||||
make defconfig > /dev/null 2> /dev/null
|
||||
grep -f "${TMP_CONFIG}-FOCUS" .config | grep -v "^#" | sort > "${TMP_CONFIG}-UPSTREAM"
|
||||
mv .config.bak .config
|
||||
|
||||
echo
|
||||
echo " --- start config diff ---"
|
||||
diff -u "${TMP_CONFIG}-LOCAL" "${TMP_CONFIG}-UPSTREAM"
|
||||
echo " --- end config diff ---"
|
||||
rm "${TMP_CONFIG}-FOCUS" "${TMP_CONFIG}-UPSTREAM" "${TMP_CONFIG}-LOCAL"
|
||||
echo
|
||||
|
||||
if [ -z "$CHECK_INSTALLED" ]; then
|
||||
echo "Checking IPK package size"
|
||||
else
|
||||
echo "Checking installed size"
|
||||
fi
|
||||
echo
|
||||
|
||||
echo "Fetching latest package indexes..."
|
||||
TMP_INDEX=$(mktemp /tmp/size_compare_package_index.XXXXXX)
|
||||
"$DOWNLOAD_METHOD" "$TARGET_URL" | gzip -d > "$TMP_INDEX" || exit 1
|
||||
"$DOWNLOAD_METHOD" "$PACKAGES_URL" | gzip -d >> "$TMP_INDEX" || exit 1
|
||||
echo
|
||||
|
||||
echo "Comparing package sizes..."
|
||||
echo "Change Local Remote Package"
|
||||
compare_sizes | sort -g -r
|
||||
|
||||
rm "$TMP_INDEX"
|
||||
@ -89,6 +89,8 @@ endif
|
||||
$(CP) -L $(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/dts/* $(IB_DTSDIR); \
|
||||
fi
|
||||
$(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(PKG_BUILD_DIR)/include/version.mk
|
||||
$(SED) 's,^# SOURCE_DATE_EPOCH:=.*,SOURCE_DATE_EPOCH:=$(SOURCE_DATE_EPOCH),g' $(PKG_BUILD_DIR)/include/version.mk
|
||||
$(SED) '/LINUX_VERMAGIC:=/ { s,unknown,$(LINUX_VERMAGIC),g }' $(PKG_BUILD_DIR)/include/kernel.mk
|
||||
find $(PKG_BUILD_DIR) -name CVS -o -name .git -o -name .svn \
|
||||
| $(XARGS) rm -rf
|
||||
$(INSTALL_DIR) $(IB_IDIR)
|
||||
|
||||
@ -1,4 +1,14 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
export INITRAMFS=1
|
||||
exec /sbin/init
|
||||
|
||||
# switch to tmpfs to allow run daemons in jail on initramfs boot
|
||||
DIRS=$(echo *)
|
||||
NEW_ROOT=/new_root
|
||||
|
||||
mkdir -p $NEW_ROOT
|
||||
mount -t tmpfs tmpfs $NEW_ROOT
|
||||
|
||||
cp -pr $DIRS $NEW_ROOT
|
||||
|
||||
exec switch_root $NEW_ROOT /sbin/init
|
||||
|
||||
@ -17,11 +17,19 @@ include $(INCLUDE_DIR)/kernel.mk
|
||||
PKG_NAME:=linux
|
||||
PKG_VERSION:=$(LINUX_VERSION)
|
||||
PKG_SOURCE:=$(LINUX_SOURCE)
|
||||
ifneq ($(strip $(CONFIG_KERNEL_GIT_CLONE_URI)),"")
|
||||
ifneq ($(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI))
|
||||
PKG_SOURCE_VERSION:=$(CONFIG_KERNEL_GIT_REF)
|
||||
PKG_SOURCE_VERSION:=$(call qstrip,$(CONFIG_KERNEL_GIT_REF))
|
||||
PKG_MIRROR_HASH:=$(call qstrip,$(CONFIG_KERNEL_GIT_MIRROR_HASH))
|
||||
ifdef CHECK
|
||||
include $(INCLUDE_DIR)/kernel-version.mk
|
||||
PKG_VERSION:=$(LINUX_VERSION)
|
||||
else
|
||||
PKG_SOURCE:=$(LINUX_SOURCE)
|
||||
endif
|
||||
else
|
||||
PKG_SOURCE:=$(LINUX_SOURCE)
|
||||
PKG_SOURCE_URL:=$(LINUX_SITE)
|
||||
endif
|
||||
HOST_BUILD_DIR:=$(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
|
||||
|
||||
@ -120,7 +120,7 @@ define PrepareStaging
|
||||
$(if $(QUIET),,set -x;) \
|
||||
mkdir -p "$$dir"; \
|
||||
cd "$$dir"; \
|
||||
mkdir -p bin lib stamp; \
|
||||
mkdir -p bin lib stamp usr/include usr/lib; \
|
||||
); done
|
||||
endef
|
||||
|
||||
|
||||
@ -7,17 +7,19 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=sstrip
|
||||
PKG_VERSION:=2.0
|
||||
PKG_VERSION:=3.1a
|
||||
|
||||
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/ELFkickers-$(PKG_VERSION)
|
||||
PKG_SOURCE_URL:=https://www.muppetlabs.com/~breadbox/pub/software
|
||||
PKG_SOURCE:=ELFkickers-$(PKG_VERSION).tar.gz
|
||||
PKG_HASH:=06430880aaf4919c5f99fc629da7000347421668c2cf32bced2d401aac276508
|
||||
|
||||
PKG_RELEASE:=1
|
||||
|
||||
include $(INCLUDE_DIR)/host-build.mk
|
||||
|
||||
define Host/Compile
|
||||
$(HOSTCC) $(HOST_CFLAGS) -include endian.h -o $(HOST_BUILD_DIR)/sstrip src/sstrip.c
|
||||
endef
|
||||
|
||||
define Host/Install
|
||||
$(CP) $(HOST_BUILD_DIR)/sstrip $(STAGING_DIR_HOST)/bin/
|
||||
$(CP) $(HOST_BUILD_DIR)/bin/sstrip $(STAGING_DIR_HOST)/bin/
|
||||
endef
|
||||
|
||||
define Host/Clean
|
||||
|
||||
28
tools/sstrip/patches/001-disable-elftoc-compilation.patch
Normal file
28
tools/sstrip/patches/001-disable-elftoc-compilation.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From: Rui Salvaterra <rsalvaterra@gmail.com>
|
||||
Subject: sstrip: don't try to compile elftoc
|
||||
|
||||
We only need sstrip itself and elftoc doesn't compile with musl's elf.h, so
|
||||
disable the elftoc compilation in the makefile.
|
||||
|
||||
Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
|
||||
---
|
||||
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
prefix = /usr/local
|
||||
|
||||
-PROGRAMS = elfls objres rebind sstrip elftoc ebfc infect
|
||||
+PROGRAMS = elfls objres rebind sstrip ebfc infect
|
||||
|
||||
all: $(PROGRAMS)
|
||||
|
||||
@@ -19,7 +19,6 @@ elfls: bin/elfls doc/elfls.1
|
||||
objres: bin/objres doc/objres.1
|
||||
rebind: bin/rebind doc/rebind.1
|
||||
sstrip: bin/sstrip doc/sstrip.1
|
||||
-elftoc: bin/elftoc doc/elftoc.1
|
||||
ebfc: bin/ebfc doc/ebfc.1
|
||||
infect: bin/infect doc/infect.1
|
||||
|
||||
@ -1,466 +0,0 @@
|
||||
/* http://www.muppetlabs.com/~breadbox/software/elfkickers.html */
|
||||
|
||||
/* sstrip: Copyright (C) 1999-2001 by Brian Raiter, under the GNU
|
||||
* General Public License. No warranty. See COPYING for details.
|
||||
*
|
||||
* Aug 23, 2004 Hacked by Manuel Novoa III <mjn3@codepoet.org> to
|
||||
* handle targets of different endianness and/or elf class, making
|
||||
* it more useful in a cross-devel environment.
|
||||
*/
|
||||
|
||||
/* ============== original README ===================
|
||||
*
|
||||
* sstrip is a small utility that removes the contents at the end of an
|
||||
* ELF file that are not part of the program's memory image.
|
||||
*
|
||||
* Most ELF executables are built with both a program header table and a
|
||||
* section header table. However, only the former is required in order
|
||||
* for the OS to load, link and execute a program. sstrip attempts to
|
||||
* extract the ELF header, the program header table, and its contents,
|
||||
* leaving everything else in the bit bucket. It can only remove parts of
|
||||
* the file that occur at the end, after the parts to be saved. However,
|
||||
* this almost always includes the section header table, and occasionally
|
||||
* a few random sections that are not used when running a program.
|
||||
*
|
||||
* It should be noted that the GNU bfd library is (understandably)
|
||||
* dependent on the section header table as an index to the file's
|
||||
* contents. Thus, an executable file that has no section header table
|
||||
* cannot be used with gdb, objdump, or any other program based upon the
|
||||
* bfd library, at all. In fact, the program will not even recognize the
|
||||
* file as a valid executable. (This limitation is noted in the source
|
||||
* code comments for bfd, and is marked "FIXME", so this may change at
|
||||
* some future date. However, I would imagine that it is a pretty
|
||||
* low-priority item, as executables without a section header table are
|
||||
* rare in the extreme.) This probably also explains why strip doesn't
|
||||
* offer the option to do this.
|
||||
*
|
||||
* Shared library files may also have their section header table removed.
|
||||
* Such a library will still function; however, it will no longer be
|
||||
* possible for a compiler to link a new program against it.
|
||||
*
|
||||
* As an added bonus, sstrip also tries to removes trailing zero bytes
|
||||
* from the end of the file. (This normally cannot be done with an
|
||||
* executable that has a section header table.)
|
||||
*
|
||||
* sstrip is a very simplistic program. It depends upon the common
|
||||
* practice of putting the parts of the file that contribute to the
|
||||
* memory image at the front, and the remaining material at the end. This
|
||||
* permits it to discard the latter material without affecting file
|
||||
* offsets and memory addresses in what remains. Of course, the ELF
|
||||
* standard permits files to be organized in almost any order, so if a
|
||||
* pathological linker decided to put its section headers at the top,
|
||||
* sstrip would be useless on such executables.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <elf.h>
|
||||
#include <byteswap.h>
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
/* The name of the program.
|
||||
*/
|
||||
static char const *progname;
|
||||
|
||||
/* The name of the current file.
|
||||
*/
|
||||
static char const *filename;
|
||||
|
||||
|
||||
/* A simple error-handling function. FALSE is always returned for the
|
||||
* convenience of the caller.
|
||||
*/
|
||||
static int err(char const *errmsg)
|
||||
{
|
||||
fprintf(stderr, "%s: %s: %s\n", progname, filename, errmsg);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* A flag to signal the need for endian reversal.
|
||||
*/
|
||||
static int do_reverse_endian;
|
||||
|
||||
/* Get a value from the elf header, compensating for endianness.
|
||||
*/
|
||||
#define EGET(X) \
|
||||
(__extension__ ({ \
|
||||
uint64_t __res; \
|
||||
if (!do_reverse_endian) { \
|
||||
__res = (X); \
|
||||
} else if (sizeof(X) == 1) { \
|
||||
__res = (X); \
|
||||
} else if (sizeof(X) == 2) { \
|
||||
__res = bswap_16((X)); \
|
||||
} else if (sizeof(X) == 4) { \
|
||||
__res = bswap_32((X)); \
|
||||
} else if (sizeof(X) == 8) { \
|
||||
__res = bswap_64((X)); \
|
||||
} else { \
|
||||
fprintf(stderr, "%s: %s: EGET failed for size %zu\n", \
|
||||
progname, filename, sizeof(X)); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} \
|
||||
__res; \
|
||||
}))
|
||||
|
||||
/* Set a value 'Y' in the elf header to 'X', compensating for endianness.
|
||||
*/
|
||||
#define ESET(Y,X) \
|
||||
do if (!do_reverse_endian) { \
|
||||
Y = (X); \
|
||||
} else if (sizeof(Y) == 1) { \
|
||||
Y = (X); \
|
||||
} else if (sizeof(Y) == 2) { \
|
||||
Y = bswap_16((uint16_t)(X)); \
|
||||
} else if (sizeof(Y) == 4) { \
|
||||
Y = bswap_32((uint32_t)(X)); \
|
||||
} else if (sizeof(Y) == 8) { \
|
||||
Y = bswap_64((uint64_t)(X)); \
|
||||
} else { \
|
||||
fprintf(stderr, "%s: %s: ESET failed for size %zu\n", \
|
||||
progname, filename, sizeof(Y)); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* A macro for I/O errors: The given error message is used only when
|
||||
* errno is not set.
|
||||
*/
|
||||
#define ferr(msg) (err(errno ? strerror(errno) : (msg)))
|
||||
|
||||
|
||||
|
||||
#define HEADER_FUNCTIONS(CLASS) \
|
||||
\
|
||||
/* readelfheader() reads the ELF header into our global variable, and \
|
||||
* checks to make sure that this is in fact a file that we should be \
|
||||
* munging. \
|
||||
*/ \
|
||||
static int readelfheader ## CLASS (int fd, Elf ## CLASS ## _Ehdr *ehdr) \
|
||||
{ \
|
||||
if (read(fd, ((char *)ehdr)+EI_NIDENT, sizeof(*ehdr) - EI_NIDENT) \
|
||||
!= sizeof(*ehdr) - EI_NIDENT) \
|
||||
return ferr("missing or incomplete ELF header."); \
|
||||
\
|
||||
/* Verify the sizes of the ELF header and the program segment \
|
||||
* header table entries. \
|
||||
*/ \
|
||||
if (EGET(ehdr->e_ehsize) != sizeof(Elf ## CLASS ## _Ehdr)) \
|
||||
return err("unrecognized ELF header size."); \
|
||||
if (EGET(ehdr->e_phentsize) != sizeof(Elf ## CLASS ## _Phdr)) \
|
||||
return err("unrecognized program segment header size."); \
|
||||
\
|
||||
/* Finally, check the file type. \
|
||||
*/ \
|
||||
if (EGET(ehdr->e_type) != ET_EXEC && EGET(ehdr->e_type) != ET_DYN) \
|
||||
return err("not an executable or shared-object library."); \
|
||||
\
|
||||
return TRUE; \
|
||||
} \
|
||||
\
|
||||
/* readphdrtable() loads the program segment header table into memory. \
|
||||
*/ \
|
||||
static int readphdrtable ## CLASS (int fd, Elf ## CLASS ## _Ehdr const *ehdr, \
|
||||
Elf ## CLASS ## _Phdr **phdrs) \
|
||||
{ \
|
||||
size_t size; \
|
||||
\
|
||||
if (!EGET(ehdr->e_phoff) || !EGET(ehdr->e_phnum) \
|
||||
) return err("ELF file has no program header table."); \
|
||||
\
|
||||
size = EGET(ehdr->e_phnum) * sizeof **phdrs; \
|
||||
if (!(*phdrs = malloc(size))) \
|
||||
return err("Out of memory!"); \
|
||||
\
|
||||
errno = 0; \
|
||||
if (read(fd, *phdrs, size) != (ssize_t)size) \
|
||||
return ferr("missing or incomplete program segment header table."); \
|
||||
\
|
||||
return TRUE; \
|
||||
} \
|
||||
\
|
||||
/* getmemorysize() determines the offset of the last byte of the file \
|
||||
* that is referenced by an entry in the program segment header table. \
|
||||
* (Anything in the file after that point is not used when the program \
|
||||
* is executing, and thus can be safely discarded.) \
|
||||
*/ \
|
||||
static int getmemorysize ## CLASS (Elf ## CLASS ## _Ehdr const *ehdr, \
|
||||
Elf ## CLASS ## _Phdr const *phdrs, \
|
||||
unsigned long *newsize) \
|
||||
{ \
|
||||
Elf ## CLASS ## _Phdr const *phdr; \
|
||||
unsigned long size, n; \
|
||||
size_t i; \
|
||||
\
|
||||
/* Start by setting the size to include the ELF header and the \
|
||||
* complete program segment header table. \
|
||||
*/ \
|
||||
size = EGET(ehdr->e_phoff) + EGET(ehdr->e_phnum) * sizeof *phdrs; \
|
||||
if (size < sizeof *ehdr) \
|
||||
size = sizeof *ehdr; \
|
||||
\
|
||||
/* Then keep extending the size to include whatever data the \
|
||||
* program segment header table references. \
|
||||
*/ \
|
||||
for (i = 0, phdr = phdrs ; i < EGET(ehdr->e_phnum) ; ++i, ++phdr) { \
|
||||
if (EGET(phdr->p_type) != PT_NULL) { \
|
||||
n = EGET(phdr->p_offset) + EGET(phdr->p_filesz); \
|
||||
if (n > size) \
|
||||
size = n; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
*newsize = size; \
|
||||
return TRUE; \
|
||||
} \
|
||||
\
|
||||
/* modifyheaders() removes references to the section header table if \
|
||||
* it was stripped, and reduces program header table entries that \
|
||||
* included truncated bytes at the end of the file. \
|
||||
*/ \
|
||||
static int modifyheaders ## CLASS (Elf ## CLASS ## _Ehdr *ehdr, \
|
||||
Elf ## CLASS ## _Phdr *phdrs, \
|
||||
unsigned long newsize) \
|
||||
{ \
|
||||
Elf ## CLASS ## _Phdr *phdr; \
|
||||
size_t i; \
|
||||
\
|
||||
/* If the section header table is gone, then remove all references \
|
||||
* to it in the ELF header. \
|
||||
*/ \
|
||||
if (EGET(ehdr->e_shoff) >= newsize) { \
|
||||
ESET(ehdr->e_shoff,0); \
|
||||
ESET(ehdr->e_shnum,0); \
|
||||
ESET(ehdr->e_shentsize,0); \
|
||||
ESET(ehdr->e_shstrndx,0); \
|
||||
} \
|
||||
\
|
||||
/* The program adjusts the file size of any segment that was \
|
||||
* truncated. The case of a segment being completely stripped out \
|
||||
* is handled separately. \
|
||||
*/ \
|
||||
for (i = 0, phdr = phdrs ; i < EGET(ehdr->e_phnum) ; ++i, ++phdr) { \
|
||||
if (EGET(phdr->p_offset) >= newsize) { \
|
||||
ESET(phdr->p_offset,newsize); \
|
||||
ESET(phdr->p_filesz,0); \
|
||||
} else if (EGET(phdr->p_offset) + EGET(phdr->p_filesz) > newsize) { \
|
||||
ESET(phdr->p_filesz, newsize - EGET(phdr->p_offset)); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
return TRUE; \
|
||||
} \
|
||||
\
|
||||
/* commitchanges() writes the new headers back to the original file \
|
||||
* and sets the file to its new size. \
|
||||
*/ \
|
||||
static int commitchanges ## CLASS (int fd, Elf ## CLASS ## _Ehdr const *ehdr, \
|
||||
Elf ## CLASS ## _Phdr *phdrs, \
|
||||
unsigned long newsize) \
|
||||
{ \
|
||||
size_t n; \
|
||||
\
|
||||
/* Save the changes to the ELF header, if any. \
|
||||
*/ \
|
||||
if (lseek(fd, 0, SEEK_SET)) \
|
||||
return ferr("could not rewind file"); \
|
||||
errno = 0; \
|
||||
if (write(fd, ehdr, sizeof *ehdr) != sizeof *ehdr) \
|
||||
return err("could not modify file"); \
|
||||
\
|
||||
/* Save the changes to the program segment header table, if any. \
|
||||
*/ \
|
||||
if (lseek(fd, EGET(ehdr->e_phoff), SEEK_SET) == (off_t)-1) { \
|
||||
err("could not seek in file."); \
|
||||
goto warning; \
|
||||
} \
|
||||
n = EGET(ehdr->e_phnum) * sizeof *phdrs; \
|
||||
if (write(fd, phdrs, n) != (ssize_t)n) { \
|
||||
err("could not write to file"); \
|
||||
goto warning; \
|
||||
} \
|
||||
\
|
||||
/* Eleventh-hour sanity check: don't truncate before the end of \
|
||||
* the program segment header table. \
|
||||
*/ \
|
||||
if (newsize < EGET(ehdr->e_phoff) + n) \
|
||||
newsize = EGET(ehdr->e_phoff) + n; \
|
||||
\
|
||||
/* Chop off the end of the file. \
|
||||
*/ \
|
||||
if (ftruncate(fd, newsize)) { \
|
||||
err("could not resize file"); \
|
||||
goto warning; \
|
||||
} \
|
||||
\
|
||||
return TRUE; \
|
||||
\
|
||||
warning: \
|
||||
return err("ELF file may have been corrupted!"); \
|
||||
}
|
||||
|
||||
|
||||
/* First elements of Elf32_Ehdr and Elf64_Ehdr are common.
|
||||
*/
|
||||
static int readelfheaderident(int fd, Elf32_Ehdr *ehdr)
|
||||
{
|
||||
errno = 0;
|
||||
if (read(fd, ehdr, EI_NIDENT) != EI_NIDENT)
|
||||
return ferr("missing or incomplete ELF header.");
|
||||
|
||||
/* Check the ELF signature.
|
||||
*/
|
||||
if (!(ehdr->e_ident[EI_MAG0] == ELFMAG0 &&
|
||||
ehdr->e_ident[EI_MAG1] == ELFMAG1 &&
|
||||
ehdr->e_ident[EI_MAG2] == ELFMAG2 &&
|
||||
ehdr->e_ident[EI_MAG3] == ELFMAG3))
|
||||
{
|
||||
err("missing ELF signature.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Compare the file's class and endianness with the program's.
|
||||
*/
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB) {
|
||||
do_reverse_endian = 0;
|
||||
} else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB) {
|
||||
/* fprintf(stderr, "ELF file has different endianness.\n"); */
|
||||
do_reverse_endian = 1;
|
||||
}
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB) {
|
||||
/* fprintf(stderr, "ELF file has different endianness.\n"); */
|
||||
do_reverse_endian = 1;
|
||||
} else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB) {
|
||||
do_reverse_endian = 0;
|
||||
}
|
||||
#else
|
||||
#error unkown endianness
|
||||
#endif
|
||||
else {
|
||||
err("Unsupported endianness");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check the target architecture.
|
||||
*/
|
||||
/* if (EGET(ehdr->e_machine) != ELF_ARCH) { */
|
||||
/* /\* return err("ELF file created for different architecture."); *\/ */
|
||||
/* fprintf(stderr, "ELF file created for different architecture.\n"); */
|
||||
/* } */
|
||||
return ehdr->e_ident[EI_CLASS];
|
||||
}
|
||||
|
||||
|
||||
HEADER_FUNCTIONS(32)
|
||||
|
||||
HEADER_FUNCTIONS(64)
|
||||
|
||||
/* truncatezeros() examines the bytes at the end of the file's
|
||||
* size-to-be, and reduces the size to exclude any trailing zero
|
||||
* bytes.
|
||||
*/
|
||||
static int truncatezeros(int fd, unsigned long *newsize)
|
||||
{
|
||||
unsigned char contents[1024];
|
||||
unsigned long size, n;
|
||||
|
||||
size = *newsize;
|
||||
do {
|
||||
n = sizeof contents;
|
||||
if (n > size)
|
||||
n = size;
|
||||
if (lseek(fd, size - n, SEEK_SET) == (off_t)-1)
|
||||
return ferr("cannot seek in file.");
|
||||
if (read(fd, contents, n) != (ssize_t)n)
|
||||
return ferr("cannot read file contents");
|
||||
while (n && !contents[--n])
|
||||
--size;
|
||||
} while (size && !n);
|
||||
|
||||
/* Sanity check.
|
||||
*/
|
||||
if (!size)
|
||||
return err("ELF file is completely blank!");
|
||||
|
||||
*newsize = size;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* main() loops over the cmdline arguments, leaving all the real work
|
||||
* to the other functions.
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
union {
|
||||
Elf32_Ehdr ehdr32;
|
||||
Elf64_Ehdr ehdr64;
|
||||
} e;
|
||||
union {
|
||||
Elf32_Phdr *phdrs32;
|
||||
Elf64_Phdr *phdrs64;
|
||||
} p;
|
||||
unsigned long newsize;
|
||||
char **arg;
|
||||
int failures = 0;
|
||||
|
||||
if (argc < 2 || argv[1][0] == '-') {
|
||||
printf("Usage: sstrip FILE...\n"
|
||||
"sstrip discards all nonessential bytes from an executable.\n\n"
|
||||
"Version 2.0-X Copyright (C) 2000,2001 Brian Raiter.\n"
|
||||
"Cross-devel hacks Copyright (C) 2004 Manuel Novoa III.\n"
|
||||
"This program is free software, licensed under the GNU\n"
|
||||
"General Public License. There is absolutely no warranty.\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
for (arg = argv + 1 ; *arg != NULL ; ++arg) {
|
||||
filename = *arg;
|
||||
|
||||
fd = open(*arg, O_RDWR);
|
||||
if (fd < 0) {
|
||||
ferr("can't open");
|
||||
++failures;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (readelfheaderident(fd, &e.ehdr32)) {
|
||||
case ELFCLASS32:
|
||||
if (!(readelfheader32(fd, &e.ehdr32) &&
|
||||
readphdrtable32(fd, &e.ehdr32, &p.phdrs32) &&
|
||||
getmemorysize32(&e.ehdr32, p.phdrs32, &newsize) &&
|
||||
truncatezeros(fd, &newsize) &&
|
||||
modifyheaders32(&e.ehdr32, p.phdrs32, newsize) &&
|
||||
commitchanges32(fd, &e.ehdr32, p.phdrs32, newsize)))
|
||||
++failures;
|
||||
break;
|
||||
case ELFCLASS64:
|
||||
if (!(readelfheader64(fd, &e.ehdr64) &&
|
||||
readphdrtable64(fd, &e.ehdr64, &p.phdrs64) &&
|
||||
getmemorysize64(&e.ehdr64, p.phdrs64, &newsize) &&
|
||||
truncatezeros(fd, &newsize) &&
|
||||
modifyheaders64(&e.ehdr64, p.phdrs64, newsize) &&
|
||||
commitchanges64(fd, &e.ehdr64, p.phdrs64, newsize)))
|
||||
++failures;
|
||||
break;
|
||||
default:
|
||||
++failures;
|
||||
break;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
return failures ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user