From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,URIBL_SBL,URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 24612 invoked from network); 27 Apr 2020 12:32:40 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with UTF8ESMTPZ; 27 Apr 2020 12:32:40 -0000 Received: (qmail 16299 invoked by uid 550); 27 Apr 2020 12:32:37 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 16281 invoked from network); 27 Apr 2020 12:32:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587990745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C9px9zspuTJxnsUHMZAf2SBJ/sfNY2FwLfrtnpSsQzo=; b=gDyI7PIjXwt6eTGWPcdQrga/FIJ0yMBqMPo60MO0l6DnQCm1sIIyE4e5X+v3Z/WdqSjQ5D XtKozoOPEp2LqkBxwp7xt4/FoG1LwOzVYEic9aTkW9N2ayGtnzPWd75IQfMX/YIhT+io4A 65qE93dpjv+Re5S/mYhZhjFIc9QMdS0= X-MC-Unique: MbdhXp_EPAaD-GhyEW3gPQ-1 From: harald@redhat.com To: musl@lists.openwall.com Cc: Harald Hoyer Date: Mon, 27 Apr 2020 14:32:07 +0200 Message-Id: <20200427123207.1025966-1-harald@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [musl] [PATCH] Enable linking to a static position independent executable From: Harald Hoyer This also enables address space layout randomization (ASLR). $ cat hello.c int main() { printf("main =3D 0x%lxd\n", main); return 0; } $ gcc -fPIE -static-pie -o hello hello.c -specs musl-gcc.specs $ ldd hello =09statically linked $ file hello hello: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), statically l= inked, with debug_info, not stripped, too many notes (256) $ ./hello main =3D 0x7f858c4e72b9d $ ./hello main =3D 0x7f0854d312b9d $ ./hello main =3D 0x7f7179a1d2b9d $ ./hello main =3D 0x7f37f981b2b9d $ readelf -l hello Elf file type is DYN (Shared object file) Entry point 0x104f There are 7 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000308 0x0000000000000308 R 0x1000 LOAD 0x0000000000001000 0x0000000000001000 0x0000000000001000 0x0000000000003eb7 0x0000000000003eb7 R E 0x1000 LOAD 0x0000000000005000 0x0000000000005000 0x0000000000005000 0x000000000000136c 0x000000000000136c R 0x1000 LOAD 0x0000000000006e50 0x0000000000007e50 0x0000000000007e50 0x00000000000002e0 0x00000000000009a0 RW 0x1000 DYNAMIC 0x0000000000006e70 0x0000000000007e70 0x0000000000007e70 0x0000000000000180 0x0000000000000180 RW 0x8 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 0x10 GNU_RELRO 0x0000000000006e50 0x0000000000007e50 0x0000000000007e50 0x00000000000001b0 0x00000000000001b0 R 0x1 Section to Segment mapping: Segment Sections... 00 .hash .gnu.hash .dynsym .dynstr .rela.dyn 01 .init .plt .text .fini 02 .rodata .eh_frame 03 .init_array .fini_array .data.rel.ro .dynamic .got .got.plt .data= .bss 04 .dynamic 05 06 .init_array .fini_array .data.rel.ro .dynamic .got --- tools/musl-gcc.specs.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 =3D> 100755 tools/musl-gcc.specs.sh diff --git a/tools/musl-gcc.specs.sh b/tools/musl-gcc.specs.sh old mode 100644 new mode 100755 index 30492574..ed584ed3 --- a/tools/musl-gcc.specs.sh +++ b/tools/musl-gcc.specs.sh @@ -17,13 +17,13 @@ cat <