From patchwork Thu Mar 22 14:38:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 132303 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp933507ljb; Thu, 22 Mar 2018 07:43:02 -0700 (PDT) X-Google-Smtp-Source: AG47ELu2dwqnnTC8ULBhaC5rH5qD93urGte3uyksbHOx1eeJ111ZedJRPHPfKKcHpdCqVB0Icdn2 X-Received: by 10.99.117.68 with SMTP id f4mr17882009pgn.369.1521729782102; Thu, 22 Mar 2018 07:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521729782; cv=none; d=google.com; s=arc-20160816; b=sB5VBOz/cQm231SnYicw2sENKgyicXLxWm4b4ZNNFFhzLv0STXcGCyVYYjGE3B4npR Vw4EJQLYlRr0ud3EhocHOSczXwv8aQKAa8A9OB4iMAoggr61qRZTL+cyyGRKUPhoYxFT Yd+CaORc0FKQyrGuRWne/2c4S5hUpJzffxR8HAwJ4I9VuNdS+igr1hZQBUIoxXo5DxIN yCYCAbFA1JUBOAOA0KFqUAvHYuSPbpf5Ug+hYM1YZcDo6idpXX4gTjp2gfiSukJjXqT0 Ko5NQ2lZbQ2czBh9Kpl1QqTMZtxWqN+Oks22VFtWNAz/qR2L+ThA3vF/8/1FoGVD6l94 ryBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=KB7uiNF+e7iNMP2nV9hVXVtWPASHhCdnSagpfFQ8aqw=; b=PNUk85jjnd/rCpjmO3COgO2dQbbNc3zbTAkFPLZzOOJN700pbvZMJMrHDoioKX8ifV aylu8cSa6zETOLMCUdNW9wOFJztbKYxvyzdSb04+f8b4AWJTk6rBmleoDr2/2pvtXhh0 ovlRi0L7csQiC1hotx492L3F9LydAgn3Am9fQ98IGcdHsaApO1O9WfgT+ynJYeTNDUtT 4KvhtWfKOUs3l/TKuL8tOVdsXxCd0cJ+xrPgnWkFSrXmZe/skLHJnXUccaGT5mDDoZ5a zl6/ex2nstjlyUZG3KRN6A0qps4HoRy3GV+Qso44SJdcIdfABKg9L1rgtJR0pw04ftgY 5rAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ROE8czMa; spf=pass (google.com: domain of binutils-return-101089-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101089-patch=linaro.org@sourceware.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n29si2350007pgd.778.2018.03.22.07.43.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 07:43:02 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-return-101089-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ROE8czMa; spf=pass (google.com: domain of binutils-return-101089-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-101089-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=TEC5mFQ3exTdf8Oc3XAc7VFgX0H+1oleIpMiw45Psjz LmA2Yo/O6l+VE4llPme4xd9PAd3ZrBwFk7kSfukwxawyFdE5NkYPi7boGcklbV9W F947bY+NZY82OPUAU+gunxpvkD8Dvcrb128LLmi1zpBbFzKLO7G1rm9eXCoQaWa8 = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; s=default; bh=UobzoPjGAnS2wwajQFBpt0W2rkQ=; b=ROE8czMaIJ7tUXnZU F6CtZbel0Dyrn+92Ef4ATU3T6WDYcczyU+yHRaAlCv+vE19Vkuo4VVx1ydY8xYT/ nqEs2/7oFVC8D/x6nvtVdQM2mV/9rO/Zt5i79Kml5jaea3Dx+4DhYyj99brv3woh t0GW5bbVh3Phm6KXcRGn8ew6vs= Received: (qmail 87674 invoked by alias); 22 Mar 2018 14:42:46 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Delivered-To: mailing list binutils@sourceware.org Received: (qmail 87652 invoked by uid 89); 22 Mar 2018 14:42:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=PROVIDE X-HELO: mx07-00178001.pphosted.com Received: from mx08-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Mar 2018 14:42:41 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w2MEd9H2000351 for ; Thu, 22 Mar 2018 15:42:38 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2gv6742m67-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Mar 2018 15:42:38 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D06D45D for ; Thu, 22 Mar 2018 14:42:37 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 74AA826E7 for ; Thu, 22 Mar 2018 14:42:37 +0000 (GMT) Received: from gnx2104.gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 22 Mar 2018 15:42:36 +0100 From: Christophe Lyon To: Subject: [ARM-FDPIC 11/12] [ARM] FDPIC: New tests. Date: Thu, 22 Mar 2018 15:38:29 +0100 Message-ID: <20180322143850.1766-12-christophe.lyon@st.com> In-Reply-To: <20180322143850.1766-1-christophe.lyon@st.com> References: <20180322143850.1766-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG4NODE1.st.com (10.75.127.10) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-22_07:, , signatures=0 X-IsSubscribed: yes 2018-XX-XX Christophe Lyon Mickaël Guêné ld/ * testsuite/ld-arm/arm-elf.exp: Execute the new FDPIC tests. * testsuite/ld-arm/fdpic-main.d: New test. * testsuite/ld-arm/fdpic-main.ld: New. * testsuite/ld-arm/fdpic-main.r: New. * testsuite/ld-arm/fdpic-main.s: New. * testsuite/ld-arm/fdpic-main.sym: New. * testsuite/ld-arm/fdpic-shared.d: New test. * testsuite/ld-arm/fdpic-shared.ld: New. * testsuite/ld-arm/fdpic-shared.r: New. * testsuite/ld-arm/fdpic-shared.s: New. * testsuite/ld-arm/fdpic-shared.sym: New. --- ld/testsuite/ld-arm/arm-elf.exp | 25 ++++ ld/testsuite/ld-arm/fdpic-main.d | 72 +++++++++++ ld/testsuite/ld-arm/fdpic-main.ld | 244 +++++++++++++++++++++++++++++++++++ ld/testsuite/ld-arm/fdpic-main.r | 11 ++ ld/testsuite/ld-arm/fdpic-main.s | 86 ++++++++++++ ld/testsuite/ld-arm/fdpic-main.sym | 14 ++ ld/testsuite/ld-arm/fdpic-shared.d | 35 +++++ ld/testsuite/ld-arm/fdpic-shared.ld | 228 ++++++++++++++++++++++++++++++++ ld/testsuite/ld-arm/fdpic-shared.r | 8 ++ ld/testsuite/ld-arm/fdpic-shared.s | 52 ++++++++ ld/testsuite/ld-arm/fdpic-shared.sym | 15 +++ 11 files changed, 790 insertions(+) create mode 100644 ld/testsuite/ld-arm/fdpic-main.d create mode 100644 ld/testsuite/ld-arm/fdpic-main.ld create mode 100644 ld/testsuite/ld-arm/fdpic-main.r create mode 100644 ld/testsuite/ld-arm/fdpic-main.s create mode 100644 ld/testsuite/ld-arm/fdpic-main.sym create mode 100644 ld/testsuite/ld-arm/fdpic-shared.d create mode 100644 ld/testsuite/ld-arm/fdpic-shared.ld create mode 100644 ld/testsuite/ld-arm/fdpic-shared.r create mode 100644 ld/testsuite/ld-arm/fdpic-shared.s create mode 100644 ld/testsuite/ld-arm/fdpic-shared.sym -- 2.6.3 diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index dd15655..c292346 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -1016,6 +1016,31 @@ set armeabitests_nonacl { "" {preempt-app.s} {{readelf -Ds preempt-app.sym}} "preempt-app"} + + {"FDPIC ARM shared library little endian" + "-shared -T fdpic-shared.ld --hash-style=sysv -EL -m armelf_linux_fdpiceabi" "" + "-EL -fdpic" {fdpic-shared.s} + {{objdump -fdw fdpic-shared.d} {objdump -Rw fdpic-shared.r} + {readelf -Ds fdpic-shared.sym}} + "fdpic-shared.so"} + {"FDPIC ARM dynamic executable little endian" + "tmpdir/fdpic-shared.so -T fdpic-main.ld --hash-style=sysv -EL -m armelf_linux_fdpiceabi" "" + "-EL -fdpic" {fdpic-main.s} + {{objdump -fdw fdpic-main.d} {objdump -Rw fdpic-main.r} + {readelf -Ds fdpic-main.sym}} + "fdpic-main"} + {"FDPIC ARM shared library big endian" + "-shared -T fdpic-shared.ld --hash-style=sysv -EB -m armelfb_linux_fdpiceabi" "" + "-EB -fdpic" {fdpic-shared.s} + {{objdump -fdw fdpic-shared.d} {objdump -Rw fdpic-shared.r} + {readelf -Ds fdpic-shared.sym}} + "fdpic-shared.so"} + {"FDPIC ARM dynamic executable big endian" + "tmpdir/fdpic-shared.so -T fdpic-main.ld --hash-style=sysv -EB -m armelfb_linux_fdpiceabi" "" + "-EB -fdpic" {fdpic-main.s} + {{objdump -fdw fdpic-main.d} {objdump -Rw fdpic-main.r} + {readelf -Ds fdpic-main.sym}} + "fdpic-main"} } # Massage the $armeabitests_common list into run_ld_link_tests standard form. diff --git a/ld/testsuite/ld-arm/fdpic-main.d b/ld/testsuite/ld-arm/fdpic-main.d new file mode 100644 index 0000000..cc129c3 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-main.d @@ -0,0 +1,72 @@ + +tmpdir/fdpic-main: file format elf32-(little|big)arm +architecture: arm.*, flags 0x00000112: +EXEC_P, HAS_SYMS, D_PAGED +start address 0x.* + +Disassembly of section .plt: + +.* <.plt>: + .*: e59fc008 ldr ip, \[pc, #8\] ; .* <.plt\+0x10> + .*: e08cc009 add ip, ip, r9 + .*: e59c9004 ldr r9, \[ip, #4\] + .*: e59cf000 ldr pc, \[ip\] + .*: 0000000c .word 0x0000000c + .*: 00000000 .word 0x00000000 + .*: e51fc00c ldr ip, \[pc, #-12\] ; .* <.plt\+0x14> + .*: e92d1000 stmfd sp!, {ip} + .*: e599c004 ldr ip, \[r9, #4\] + .*: e599f000 ldr pc, \[r9\] + .*: e59fc008 ldr ip, \[pc, #8\] ; .* <.plt\+0x38> + .*: e08cc009 add ip, ip, r9 + .*: e59c9004 ldr r9, \[ip, #4\] + .*: e59cf000 ldr pc, \[ip] + .*: 00000014 .word 0x00000014 + .*: 00000008 .word 0x00000008 + .*: e51fc00c ldr ip, \[pc, #-12\] ; .* <.plt\+0x3c> + .*: e92d1000 stmfd sp!, {ip} + .*: e599c004 ldr ip, \[r9, #4\] + .*: e599f000 ldr pc, \[r9\] + +Disassembly of section .text: + +.* <_start>: + .*: eaffffff b .*
+ +.*
: + .*: e59f206c ldr r2, \[pc, #108\] ; .* + .*: e59f306c ldr r3, \[pc, #108\] ; .* + .*: e92d4070 push {r4, r5, r6, lr} + .*: e7995002 ldr r5, \[r9, r2\] + .*: e1a04009 mov r4, r9 + .*: e7993003 ldr r3, \[r9, r3\] + .*: e5853000 str r3, \[r5\] + .*: ebffffe2 bl .* <.plt> + .*: e1a06000 mov r6, r0 + .*: e1a09004 mov r9, r4 + .*: e5950000 ldr r0, \[r5\] + .*: e1a09004 mov r9, r4 + .*: ebffffe7 bl .* <.plt\+0x28> + .*: e59f3040 ldr r3, \[pc, #64\] ; .* + .*: e1a09004 mov r9, r4 + .*: e0833009 add r3, r3, r9 + .*: e1a00003 mov r0, r3 + .*: e5853000 str r3, \[r5\] + .*: e1a09004 mov r9, r4 + .*: ebffffe0 bl .* <.plt\+0x28> + .*: e59f3028 ldr r3, \[pc, #40\] ; .* + .*: e1a09004 mov r9, r4 + .*: e7993003 ldr r3, \[r9, r3\] + .*: e5930000 ldr r0, \[r3\] + .*: e1a09004 mov r9, r4 + .*: ebffffda bl .* <.plt\+0x28> + .*: e1a00006 mov r0, r6 + .*: e1a09004 mov r9, r4 + .*: e8bd8070 pop {r4, r5, r6, pc} + .*: 0000002c .word 0x0000002c + .*: 00000024 .word 0x00000024 + .*: 0000001c .word 0x0000001c + .*: 00000028 .word 0x00000028 + +.* : + .*: e12fff1e bx lr diff --git a/ld/testsuite/ld-arm/fdpic-main.ld b/ld/testsuite/ld-arm/fdpic-main.ld new file mode 100644 index 0000000..4208c66 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-main.ld @@ -0,0 +1,244 @@ +/* Script for -z combreloc: combine and sort reloc sections */ +OUTPUT_FORMAT("elf32-littlearm-fdpic", "elf32-bigarm-fdpic", + "elf32-littlearm-fdpic") +OUTPUT_ARCH(arm) +ENTRY(_start) +SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x00008000)); . = SEGMENT_START("text-segment", 0x00008000) + SIZEOF_HEADERS; + .interp : { *(.interp) } + .note.gnu.build-id : { *(.note.gnu.build-id) } + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.dyn : + { + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + PROVIDE_HIDDEN (__rel_iplt_start = .); + *(.rel.iplt) + PROVIDE_HIDDEN (__rel_iplt_end = .); + PROVIDE_HIDDEN (__rela_iplt_start = .); + PROVIDE_HIDDEN (__rela_iplt_end = .); + } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + PROVIDE_HIDDEN (__rel_iplt_start = .); + PROVIDE_HIDDEN (__rel_iplt_end = .); + PROVIDE_HIDDEN (__rela_iplt_start = .); + *(.rela.iplt) + PROVIDE_HIDDEN (__rela_iplt_end = .); + } + .rel.plt : + { + *(.rel.plt) + } + .rela.plt : + { + *(.rela.plt) + } + .init : + { + KEEP (*(.init)) + } =0 + .plt : { *(.plt) } + .iplt : { *(.iplt) } + .text : + { + *(.text.unlikely .text.*_unlikely) + *(.text.exit .text.exit.*) + *(.text.startup .text.startup.*) + *(.text.hot .text.hot.*) + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx) + } =0 + .fini : + { + KEEP (*(.fini)) + } =0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } + PROVIDE_HIDDEN (__exidx_start = .); + .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } + PROVIDE_HIDDEN (__exidx_end = .); + .rofixup : { + __ROFIXUP_LIST__ = .; + *(.rofixup) + __ROFIXUP_END__ = .; +} + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table + .gcc_except_table.*) } + /* These sections are generated by the Sun/Oracle C++ compiler. */ + .exception_ranges : ONLY_IF_RO { *(.exception_ranges + .exception_ranges*) } + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); + /* Exception handling */ + .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } + /* Thread Local Storage sections */ + .tdata : + { + PROVIDE_HIDDEN (__tdata_start = .); + *(.tdata .tdata.* .gnu.linkonce.td.*) + } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + } + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } + .dynamic : { *(.dynamic) } + . = DATA_SEGMENT_RELRO_END (0, .); + .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } + .data : + { + PROVIDE (__data_start = .); + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + _edata = .; PROVIDE (edata = .); + __bss_start = .; + __bss_start__ = .; + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + . = ALIGN(. != 0 ? 32 / 8 : 1); + } + _bss_end__ = . ; __bss_end__ = . ; + . = ALIGN(32 / 8); + . = ALIGN(32 / 8); + __end__ = . ; + _end = .; PROVIDE (end = .); + . = DATA_SEGMENT_END (.); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } + .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } +} diff --git a/ld/testsuite/ld-arm/fdpic-main.r b/ld/testsuite/ld-arm/fdpic-main.r new file mode 100644 index 0000000..ec012ff --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-main.r @@ -0,0 +1,11 @@ + +tmpdir/fdpic-main.*: file format elf32-(little|big)arm + +DYNAMIC RELOCATION RECORDS +OFFSET TYPE VALUE +.* R_ARM_FUNCDESC my_shared_func1 +.* R_ARM_FUNCDESC my_shared_func1 +.* R_ARM_FUNCDESC_VALUE my_shared_func1 +.* R_ARM_FUNCDESC_VALUE my_shared_func2 + + diff --git a/ld/testsuite/ld-arm/fdpic-main.s b/ld/testsuite/ld-arm/fdpic-main.s new file mode 100644 index 0000000..7e1ada9 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-main.s @@ -0,0 +1,86 @@ + .arch armv7-r + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 26, 2 + .eabi_attribute 30, 2 + .eabi_attribute 34, 1 + .eabi_attribute 18, 4 + .file "hello.c" + .text + .align 2 + .syntax unified + .arm + .fpu softvfp + .type my_local_func, %function +my_local_func: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + @ link register save eliminated. + bx lr + .size my_local_func, .-my_local_func + .section .text.startup,"ax",%progbits + .align 2 + .global _start + .syntax unified + .arm + .fpu softvfp + .type _start, %function +_start: + b main + + .global main + .syntax unified + .arm + .fpu softvfp + .type main, %function +main: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + ldr r2, .L4 + ldr r3, .L4+4 + push {r4, r5, r6, lr} + ldr r5, [r9, r2] + mov r4, r9 + ldr r3, [r9, r3] + str r3, [r5] + bl my_shared_func1(PLT) + mov r6, r0 + mov r9, r4 + ldr r0, [r5] + mov r9, r4 + bl my_shared_func2(PLT) + ldr r3, .L4+8 + mov r9, r4 + add r3, r3, r9 + mov r0, r3 + str r3, [r5] + mov r9, r4 + bl my_shared_func2(PLT) + ldr r3, .L4+12 + mov r9, r4 + ldr r3, [r9, r3] + ldr r0, [r3] + mov r9, r4 + bl my_shared_func2(PLT) + mov r0, r6 + mov r9, r4 + pop {r4, r5, r6, pc} +.L5: + .align 2 +.L4: + .word funcptr(GOT) + .word my_shared_func1(GOTFUNCDESC) + .word my_local_func(GOTOFFFUNCDESC) + .word funcptr2(GOT) + .size main, .-main + .global funcptr2 + .comm funcptr,4,4 + .section .data.rel,"aw",%progbits + .align 2 + .type funcptr2, %object + .size funcptr2, 4 +funcptr2: + .word my_shared_func1(FUNCDESC) diff --git a/ld/testsuite/ld-arm/fdpic-main.sym b/ld/testsuite/ld-arm/fdpic-main.sym new file mode 100644 index 0000000..9eaf617 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-main.sym @@ -0,0 +1,14 @@ + +Symbol table for image: + +Num +Buc: +Value +Size +Type +Bind +Vis +Ndx +Name + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +12 _edata + +.. +..: ........ +0 +FUNC +GLOBAL +DEFAULT +UND my_shared_func2 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +12 __bss_start__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +13 _end + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +13 __bss_end__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +13 __end__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT + 9 __ROFIXUP_LIST__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +12 __bss_start + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT + 9 __ROFIXUP_END__ + +.. +..: ........ +0 +FUNC +GLOBAL +DEFAULT +UND my_shared_func1 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +13 _bss_end__ diff --git a/ld/testsuite/ld-arm/fdpic-shared.d b/ld/testsuite/ld-arm/fdpic-shared.d new file mode 100644 index 0000000..438c0e9 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-shared.d @@ -0,0 +1,35 @@ + +tmpdir/fdpic-shared.so: file format elf32-(little|big)arm +architecture: arm.*, flags 0x00000150: +HAS_SYMS, DYNAMIC, D_PAGED +start address 0x.* + +Disassembly of section .plt: + +.* <.plt>: + .*: e59fc008 ldr ip, \[pc, #8\] ; .* <.plt\+0x10> + .*: e08cc009 add ip, ip, r9 + .*: e59c9004 ldr r9, \[ip, #4\] + .*: e59cf000 ldr pc, \[ip\] + .*: 0000000c .word 0x0000000c + .*: 00000000 .word 0x00000000 + .*: e51fc00c ldr ip, \[pc, #-12\] ; .* <.plt\+0x14> + .*: e92d1000 stmfd sp!, {ip} + .*: e599c004 ldr ip, \[r9, #4\] + .*: e599f000 ldr pc, \[r9\] + +Disassembly of section .text: + +.* : + .*: e12fff1e bx lr + +.* : + .*: e3a00000 mov r0, #0 + .*: e12fff1e bx lr + +.* : + .*: e92d4010 push {r4, lr} + .*: e1a04009 mov r4, r9 + .*: ebffffef bl .* <.plt> + .*: e1a09004 mov r9, r4 + .*: e8bd8010 pop {r4, pc} diff --git a/ld/testsuite/ld-arm/fdpic-shared.ld b/ld/testsuite/ld-arm/fdpic-shared.ld new file mode 100644 index 0000000..450d6f9 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-shared.ld @@ -0,0 +1,228 @@ +/* Script for --shared -z combreloc: shared library, combine & sort relocs */ +OUTPUT_FORMAT("elf32-littlearm-fdpic", "elf32-bigarm-fdpic", + "elf32-littlearm-fdpic") +OUTPUT_ARCH(arm) +ENTRY(_start) +SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; + .note.gnu.build-id : { *(.note.gnu.build-id) } + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.dyn : + { + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + *(.rel.iplt) + } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + *(.rela.iplt) + } + .rel.plt : + { + *(.rel.plt) + } + .rela.plt : + { + *(.rela.plt) + } + .init : + { + KEEP (*(.init)) + } =0 + .plt : { *(.plt) } + .iplt : { *(.iplt) } + .text : + { + *(.text.unlikely .text.*_unlikely) + *(.text.exit .text.exit.*) + *(.text.startup .text.startup.*) + *(.text.hot .text.hot.*) + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx) + } =0 + .fini : + { + KEEP (*(.fini)) + } =0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } + PROVIDE_HIDDEN (__exidx_start = .); + .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } + PROVIDE_HIDDEN (__exidx_end = .); + .rofixup : { + __ROFIXUP_LIST__ = .; + *(.rofixup) + __ROFIXUP_END__ = .; + } + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table + .gcc_except_table.*) } + /* These sections are generated by the Sun/Oracle C++ compiler. */ + .exception_ranges : ONLY_IF_RO { *(.exception_ranges + .exception_ranges*) } + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); + /* Exception handling */ + .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } + /* Thread Local Storage sections */ + .tdata : + { + *(.tdata .tdata.* .gnu.linkonce.td.*) + } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } + .preinit_array : + { + KEEP (*(.preinit_array)) + } + .init_array : + { + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + } + .fini_array : + { + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + } + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } + .dynamic : { *(.dynamic) } + . = DATA_SEGMENT_RELRO_END (0, .); + .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } + .data : + { + PROVIDE (__data_start = .); + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + _edata = .; PROVIDE (edata = .); + __bss_start = .; + __bss_start__ = .; + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + . = ALIGN(. != 0 ? 32 / 8 : 1); + } + _bss_end__ = . ; __bss_end__ = . ; + . = ALIGN(32 / 8); + . = ALIGN(32 / 8); + __end__ = . ; + _end = .; PROVIDE (end = .); + . = DATA_SEGMENT_END (.); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } + .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } +} diff --git a/ld/testsuite/ld-arm/fdpic-shared.r b/ld/testsuite/ld-arm/fdpic-shared.r new file mode 100644 index 0000000..22b755e --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-shared.r @@ -0,0 +1,8 @@ + +tmpdir/fdpic-shared.so: file format elf32-(little|big)arm + +DYNAMIC RELOCATION RECORDS +OFFSET TYPE VALUE +.* R_ARM_FUNCDESC_VALUE my_shared_func3 + + diff --git a/ld/testsuite/ld-arm/fdpic-shared.s b/ld/testsuite/ld-arm/fdpic-shared.s new file mode 100644 index 0000000..a5baf3b --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-shared.s @@ -0,0 +1,52 @@ + .arch armv7-r + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .eabi_attribute 24, 1 + .eabi_attribute 25, 1 + .eabi_attribute 26, 2 + .eabi_attribute 30, 2 + .eabi_attribute 34, 1 + .eabi_attribute 18, 4 + .file "shared.c" + .text + .align 2 + .global my_shared_func1 + .syntax unified + .arm + .fpu softvfp + .type my_shared_func1, %function +my_shared_func1: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + @ link register save eliminated. + bx lr + .size my_shared_func1, .-my_shared_func1 + .align 2 + .global my_shared_func3 + .syntax unified + .arm + .fpu softvfp + .type my_shared_func3, %function +my_shared_func3: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + @ link register save eliminated. + mov r0, #0 + bx lr + .size my_shared_func3, .-my_shared_func3 + .align 2 + .global my_shared_func2 + .syntax unified + .arm + .fpu softvfp + .type my_shared_func2, %function +my_shared_func2: + @ args = 0, pretend = 0, frame = 0 + @ frame_needed = 0, uses_anonymous_args = 0 + push {r4, lr} + mov r4, r9 + bl my_shared_func3(PLT) + mov r9, r4 + pop {r4, pc} + .size my_shared_func2, .-my_shared_func2 diff --git a/ld/testsuite/ld-arm/fdpic-shared.sym b/ld/testsuite/ld-arm/fdpic-shared.sym new file mode 100644 index 0000000..2938b36 --- /dev/null +++ b/ld/testsuite/ld-arm/fdpic-shared.sym @@ -0,0 +1,15 @@ + +Symbol table for image: + +Num +Buc: +Value +Size +Type +Bind +Vis +Ndx +Name + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 _edata + +.. +..: ........ +20 +FUNC +GLOBAL +DEFAULT +6 my_shared_func2 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 __bss_start__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 _end + +.. +..: ........ +8 +FUNC +GLOBAL +DEFAULT +6 my_shared_func3 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 __bss_end__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 __end__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +7 __ROFIXUP_LIST__ + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 __bss_start + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +7 __ROFIXUP_END__ + +.. +..: ........ +4 +FUNC +GLOBAL +DEFAULT +6 my_shared_func1 + +.. +..: ........ +0 +NOTYPE +GLOBAL +DEFAULT +9 _bss_end__