From patchwork Thu Aug 27 19:11:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Douglas RAILLARD X-Patchwork-Id: 511396 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 382D0140081 for ; Fri, 28 Aug 2015 05:11:28 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=mhpgGj/N; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 6A9271FDF5; Thu, 27 Aug 2015 19:11:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xxJTOiiNsPVg; Thu, 27 Aug 2015 19:11:24 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 887B02F270; Thu, 27 Aug 2015 19:11:24 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 885691BF863 for ; Thu, 27 Aug 2015 19:11:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 6370191FA1 for ; Thu, 27 Aug 2015 19:11:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dN7zQck98BPY for ; Thu, 27 Aug 2015 19:11:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by whitealder.osuosl.org (Postfix) with ESMTPS id 68CB091EF4 for ; Thu, 27 Aug 2015 19:11:21 +0000 (UTC) Received: by wicne3 with SMTP id ne3so1399283wic.0 for ; Thu, 27 Aug 2015 12:11:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-transfer-encoding:content-type; bh=xRZXJ6pAunUVA4+Yw73riSvL8IydZu6S//FMPo58l8g=; b=mhpgGj/NR3UPbgQkESdLjGCfDCmSJVx5KGpHejtarvVXSsP+tB1VHTVD+Il9X1n8JW mHa2//CXCJfTg9hCKgicml8cA7FUkDXcsDmYrW9Us73JhIdyX0QxTem30rFb6q5v7UuJ PiMVfPBrGAm4sBpRyJwW9sq2299h7WWRUazRBjvSJgtcf4Lcm9JLG2pe+3RHJeuSYbbr GbaQC1ZStXsU/25qGS3Aj0v2dglUdFt19IfmiV5qds93v/hrac48/JRfDbweR+0QCLjl aWDLc9vUa3745Y4EN/Rc7+Fn5NOzV2eFxcxJwsfsbtSnVoFKdzPVWciLSULgbyj1wHpm x4uQ== X-Received: by 10.180.100.74 with SMTP id ew10mr215330wib.12.1440702680093; Thu, 27 Aug 2015 12:11:20 -0700 (PDT) Received: from raillard-dv6.localnet (ALyon-658-1-68-8.w109-212.abo.wanadoo.fr. [109.212.123.8]) by smtp.gmail.com with ESMTPSA id du6sm114970wib.24.2015.08.27.12.11.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2015 12:11:19 -0700 (PDT) From: Douglas RAILLARD To: buildroot@buildroot.org Date: Thu, 27 Aug 2015 21:11:18 +0200 Message-ID: <1990856.EDz1xKh0BM@raillard-dv6> User-Agent: KMail/4.14.10 (Linux/3.14.51-1-lts; KDE/4.14.11; x86_64; ; ) MIME-Version: 1.0 Subject: [Buildroot] elf2flt .ARM.exidx and .ARM.extab section handling X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Hi everybody, Cortex M3 no-MMU toolchain includes the elf2flt tool to convert ELF to bFLT. However, it does not seem to be able to do its job when given the ELF output of gcc 4.9.3 and uClibc 0.9.33. The problem is: .ARM.exidx sections and .ARM.extab input sections are not kept by the elf2flt linker script and libgcc apparently needs that information (actually, a symbol for the beginning and the end of the .ARM.exidx sections): output/build/host-gcc-final-4.9.3/build/arm-buildroot-uclinux-uclibcgnueabi/libgcc/../../../libgcc/unwind-arm-common.inc:275: undefined reference to « __exidx_start » This error shows up during the final link of a binary, not when compiling the toolchain itself. A patch has been sent here 3 years ago but for some reasons, has not been checked in buildroot: http://article.gmane.org/gmane.comp.lib.uclibc.buildroot/40885/match=elf2flt Now elf2flt sources had been moved out of the buildroot tree, but the currently used upstream has no obvious mean of contact so here is a serie of small patches that allow the elf2flt toolchain to compile cleanly C code (C++ not tested). Also, support for two relocations types (R_ARM_NONE, R_ARM_PREL31) must be added to elf2flt in order to process the content of .ARM.exidx section. Note that I have not already tested the resulting binaries, only that buildroot builds the root image without error, but Sourcery 2010q1 uClinux prebuilt toolchain default linker script does a similar thing. Unfortunately, I have not been able to find the sources of the elf2flt binary included in that prebuilt toolchain yet. Here is the URL of that prebuilt toolchain: https://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/arm-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 --- host-elf2flt-21c6a41885ad544763ccd19883c1353f3b0b7a47/elf2flt.ld.in 2012-10-04 04:32:38.000000000 +0200 +++ host-elf2flt-21c6a41885ad544763ccd19883c1353f3b0b7a47/elf2flt.ld.in 2015-08-27 17:21:14.115151557 +0200 @@ -142,8 +142,12 @@ .gcc_except_table : { KEEP(*(.gcc_except_table)) KEEP(*(.gcc_except_table.*)) - } >flatmem - + } >flatmem + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } > flatmem + PROVIDE_HIDDEN (@SYMBOL_PREFIX@__exidx_start = .); + .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } > flatmem + PROVIDE_HIDDEN (@SYMBOL_PREFIX@__exidx_end = .); + . = ALIGN(0x10) ; @SYMBOL_PREFIX@_edata = . ; --- host-elf2flt-21c6a41885ad544763ccd19883c1353f3b0b7a47//elf2flt.c 2012-10-04 04:32:38.000000000 +0200 +++ host-elf2flt-21c6a41885ad544763ccd19883c1353f3b0b7a47/elf2flt.c 2015-08-27 16:42:51.599398857 +0200 @@ -638,6 +638,8 @@ case R_ARM_ABS32: relocation_needed = 1; break; + case R_ARM_NONE: + case R_ARM_PREL31: case R_ARM_REL32: case R_ARM_THM_PC11: case R_ARM_THM_PC22: --- host-elf2flt-21c6a41885ad544763ccd19883c1353f3b0b7a47/cygwin-elf.h 2012-10-04 04:32:38.000000000 +0200 +++ host-elf2flt-21c6a41885ad544763ccd19883c1353f3b0b7a47/cygwin-elf.h 2015-08-25 23:00:09.971202559 +0200 @@ -1882,6 +1882,7 @@ #define R_ARM_LDR_SBREL_11_0 35 #define R_ARM_ALU_SBREL_19_12 36 #define R_ARM_ALU_SBREL_27_20 37 +#define R_ARM_PREL31 42 /* 32 bit PLT address */ #define R_ARM_GNU_VTENTRY 100 #define R_ARM_GNU_VTINHERIT 101 #define R_ARM_THM_PC11 102 /* thumb unconditional branch */