Переглянути джерело

uclibc-ng: do not clobber Scrt1.o with the non-PIC crt1.o

Commit e69f684de (support nommu with ELF binaries) unconditionally
hardlinks Scrt1.o to crt1.o after install.  On MMU targets with shared
library support uClibc-ng installs a proper PIC Scrt1.o, and the link
replaces it with the non-PIC startup object: every PIE linked against
the toolchain then carries absolute relocations in .text

    ld: Scrt1.o: warning: relocation against `_init' in read-only
        section `.text'
    ld: warning: creating DT_TEXTREL in a PIE

which breaks W^X and fails on hardened kernels.  Keep the link as a
fallback for the noMMU/FLAT configurations it was added for, but only
when uClibc-ng did not install an Scrt1.o itself.

Signed-off-by: Ramin Moussavi <ramin.moussavi@yacoub.de>
ramin 1 місяць тому
батько
коміт
9ff37cdcf9
1 змінених файлів з 3 додано та 2 видалено
  1. 3 2
      toolchain/uclibc-ng/Makefile

+ 3 - 2
toolchain/uclibc-ng/Makefile

@@ -400,8 +400,9 @@ $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
 		UCLIBC_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
 		VERBOSE=1 \
 		install_runtime install_dev
-	ln -f ${STAGING_TARGET_DIR}/usr/lib/crt1.o \
-		${STAGING_TARGET_DIR}/usr/lib/Scrt1.o
+	test -e ${STAGING_TARGET_DIR}/usr/lib/Scrt1.o || \
+		ln -f ${STAGING_TARGET_DIR}/usr/lib/crt1.o \
+			${STAGING_TARGET_DIR}/usr/lib/Scrt1.o
 ifeq ($(ADK_TARGET_LIBC_UTILS),y)
 	PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
 		ARCH="$(ADK_TARGET_ARCH)" \