From patchwork Thu Aug 27 17:54:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 52777 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by patches.linaro.org (Postfix) with ESMTPS id B4E3C22E8B for ; Thu, 27 Aug 2015 18:09:28 +0000 (UTC) Received: by lbbpd10 with SMTP id pd10sf9316347lbb.3 for ; Thu, 27 Aug 2015 11:09:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=2n5VnDMe8H6RQw95J+4F1GDwJNHmd9AnHExe7dLrAiw=; b=GyHzgvKRbiGWCXHJT140Q8J15kutLjwawHAdnmA3P5cxfCTMlmS/AP/4nnfYoaDeME xIjs1gG6adpFFxitCnYv7z2pBI/J4Hyd+5vlaXJLmI/wj0GRHMGyDdJMYuDSVxUk/er3 22CSE0d5wY7P16gniJbAkQviC5b3b7xlzJ+v2LqDzOYQnGpTa0w+gqQKXaES1o9XasCU aFEhtc8IpSuc3kFChCayJlu7X1zNd5Ie4ltHqmRJyQEAugqgJpLSqzJCtjIE7hhIDGkt +XAcAOGoXJEkFGMFLjgkljpXBoX869ruzjer/m1I+CFyFL95YcDcmzo6V+d+iXdjJpK0 MGgQ== X-Gm-Message-State: ALoCoQmiSCKP/+Xuqx/dTYkjcUt11U7AMGErNp8NGmfE9ae9hYrheCq73zr3Xf4dVidDW/3sUHDJ X-Received: by 10.152.29.36 with SMTP id g4mr1534238lah.3.1440698967527; Thu, 27 Aug 2015 11:09:27 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.9 with SMTP id ku9ls102572lac.37.gmail; Thu, 27 Aug 2015 11:09:27 -0700 (PDT) X-Received: by 10.152.44.196 with SMTP id g4mr2942290lam.56.1440698967393; Thu, 27 Aug 2015 11:09:27 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id jm1si3051581lbc.84.2015.08.27.11.09.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2015 11:09:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by laaa3 with SMTP id a3so8796106laa.2 for ; Thu, 27 Aug 2015 11:09:27 -0700 (PDT) X-Received: by 10.152.164.130 with SMTP id yq2mr2426630lab.76.1440698967237; Thu, 27 Aug 2015 11:09:27 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.151.194 with SMTP id us2csp3264lbb; Thu, 27 Aug 2015 11:09:26 -0700 (PDT) X-Received: by 10.66.139.234 with SMTP id rb10mr8498143pab.118.1440698966243; Thu, 27 Aug 2015 11:09:26 -0700 (PDT) Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com. [209.85.220.48]) by mx.google.com with ESMTPS id b1si5058368pat.26.2015.08.27.11.09.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2015 11:09:26 -0700 (PDT) Received-SPF: pass (google.com: domain of yang.shi@linaro.org designates 209.85.220.48 as permitted sender) client-ip=209.85.220.48; Received: by pacti10 with SMTP id ti10so33967800pac.0 for ; Thu, 27 Aug 2015 11:09:25 -0700 (PDT) X-Received: by 10.68.218.104 with SMTP id pf8mr8477759pbc.31.1440698965295; Thu, 27 Aug 2015 11:09:25 -0700 (PDT) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id xf6sm3124439pbc.70.2015.08.27.11.09.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2015 11:09:24 -0700 (PDT) From: Yang Shi To: yang.shi@windriver.com Cc: patches@linaro.org, linaro-kernel@lists.linaro.org, Yang Shi Subject: [PATCH] Force text segment alignment to 0x08000000 for i386 with gold linker Date: Thu, 27 Aug 2015 10:54:12 -0700 Message-Id: <1440698053-12155-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: yang.shi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When build libhugetlbfs tests with gold linker for i386, the below error occurs: i586-oe-linux-gcc -m32 -march=i586 -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed --sysroot=/home/jenkins/oe/world/shr-core/tmp-glibc/sysroots/qemux86 -I.. -O2 -Wall -g -o obj32/linkhuge_rw.o -c linkhuge_rw.c | i586-oe-linux-gcc -m32 -march=i586 -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed --sysroot=/home/jenkins/oe/world/shr-core/tmp-glibc/sysroots/qemux86 -B./obj32 -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,noexecstack -ldl -L../obj32 -o obj32/linkhuge_rw -Wl,--no-as-needed -lpthread -ldl -lhugetlbfs_privutils -Wl,--hugetlbfs-align obj32/linkhuge_rw.o obj32/testutils.o | i586-oe-linux-ld: internal error in do_write, at /home/jenkins/oe/world/shr-core/tmp-glibc/work/x86_64-oe-linux/binutils-cross-i586/2.25-r0/git/gold/output.cc:464 | collect2: error: ld returned 1 exit status But, it works well with GNU linker. --hugetlbfs-align flag passes "-zcommon-page-size=$SLICE_SIZE -zmax-page-size=$SLICE_SIZE", that are supported by gold linker too. But, it looks gold linker deal with them in a different way from gnu linker for i586. The readelf shows the below result with GNU linker: Elf file type is EXEC (Executable file) Entry point 0x8048fbd There are 8 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PHDR 0x000034 0x08000034 0x08000034 0x00100 0x00100 R E 0x4 INTERP 0x048134 0x08048134 0x08048134 0x00013 0x00013 R 0x1 [Requesting program interpreter: /lib/ld-linux.so.2] LOAD 0x000000 0x08000000 0x08000000 0x5a5bc 0x5a5bc R E 0x400000 LOAD 0x05a5bc 0x0845a5bc 0x0845a5bc 0x1028c 0x202cc RW 0x400000 DYNAMIC 0x05a5d0 0x0845a5d0 0x0845a5d0 0x000e8 0x000e8 RW 0x4 NOTE 0x048148 0x08048148 0x08048148 0x00044 0x00044 R 0x4 GNU_EH_FRAME 0x059e5c 0x08059e5c 0x08059e5c 0x0009c 0x0009c R 0x4 GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x10 "--relax" linker option doesn't solve this problem. Forced textsegment alignment to 0x08000000 with gold linker, the build will pass and readelf shows the same result with GNU linker: Elf file type is EXEC (Executable file) Entry point 0x8048fbd There are 8 program headers, starting at offset 52 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PHDR 0x000034 0x08000034 0x08000034 0x00100 0x00100 R E 0x4 INTERP 0x048134 0x08048134 0x08048134 0x00013 0x00013 R 0x1 [Requesting program interpreter: /lib/ld-linux.so.2] LOAD 0x000000 0x08000000 0x08000000 0x5a5bc 0x5a5bc R E 0x400000 LOAD 0x05a5bc 0x0845a5bc 0x0845a5bc 0x1028c 0x202cc RW 0x400000 DYNAMIC 0x05a5d0 0x0845a5d0 0x0845a5d0 0x000e8 0x000e8 RW 0x4 NOTE 0x048148 0x08048148 0x08048148 0x00044 0x00044 R 0x4 GNU_EH_FRAME 0x059e5c 0x08059e5c 0x08059e5c 0x0009c 0x0009c R 0x4 GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x10 The fix just have impact on hugelink_rw test case, which needs --hugetlbfs-align flag. Signed-off-by: Yang Shi --- ld.hugetlbfs | 1 + 1 file changed, 1 insertion(+) diff --git a/ld.hugetlbfs b/ld.hugetlbfs index 4417442..32bc6fb 100755 --- a/ld.hugetlbfs +++ b/ld.hugetlbfs @@ -98,6 +98,7 @@ if [ "$HTLB_ALIGN" == "slice" ]; then # otherwise it will be NULL. case "$EMU" in armelf*_linux_eabi) HTLBOPTS="$HTLBOPTS -Ttext-segment=$SLICE_SIZE" ;; + elf_i386) HTLBOPTS="$HTLBOPTS -Ttext-segment=0x08000000" ;; esac fi