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=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 17224 invoked from network); 6 Apr 2020 17:59:19 -0000 Received-SPF: pass (mother.openwall.net: domain of lists.openwall.com designates 195.42.179.200 as permitted sender) receiver=inbox.vuxu.org; client-ip=195.42.179.200 envelope-from= Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with UTF8ESMTPZ; 6 Apr 2020 17:59:19 -0000 Received: (qmail 13829 invoked by uid 550); 6 Apr 2020 17:59:15 -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 13811 invoked from network); 6 Apr 2020 17:59:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586195943; 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; bh=hVAvQBtLsO9Lv+wIdZ0Ncx4T+opITDx0IDho5JR5ZnM=; b=cAeTqaWsg2eFH4mOVqNZha9RlxIB0aG9AU3NFaJ/cfP8LWLglVcVD311jW0aGtuDaTZXZ2 m1KS/PMhZ5wmKkb8rtE1btNFjGDxB9YchYw4/dDUbrk8G6iJAV+ToyRPwdeI/cnChkWuyt ZEibol5tWBB5IxnRO+Zf5nYc7IfwzDs= X-MC-Unique: tMJ_WooWOHma1HpBmbFpyw-1 From: harald@redhat.com To: musl@lists.openwall.com Cc: Harald Hoyer Date: Mon, 6 Apr 2020 19:58:43 +0200 Message-Id: <20200406175843.944022-1-harald@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 -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, BuildID[sha1]=3D24fe0d02b0558dc37b8ae2268878b118804ae72d, with debug= _info, not stripped $ ./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 0x1058 There are 9 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x00000000000003c0 0x00000000000003c0 R 0x1000 LOAD 0x0000000000001000 0x0000000000001000 0x0000000000001000 0x0000000000002cce 0x0000000000002cce R E 0x1000 LOAD 0x0000000000004000 0x0000000000004000 0x0000000000004000 0x0000000000001550 0x0000000000001550 R 0x1000 LOAD 0x0000000000005e50 0x0000000000006e50 0x0000000000006e50 0x00000000000002e0 0x00000000000009a0 RW 0x1000 DYNAMIC 0x0000000000005e70 0x0000000000006e70 0x0000000000006e70 0x0000000000000170 0x0000000000000170 RW 0x8 NOTE 0x0000000000000238 0x0000000000000238 0x0000000000000238 0x0000000000000024 0x0000000000000024 R 0x4 GNU_EH_FRAME 0x0000000000004b60 0x0000000000004b60 0x0000000000004b60 0x00000000000001ec 0x00000000000001ec R 0x4 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 0x10 GNU_RELRO 0x0000000000005e50 0x0000000000006e50 0x0000000000006e50 0x00000000000001b0 0x00000000000001b0 R 0x1 Section to Segment mapping: Segment Sections... 00 .note.gnu.build-id .gnu.hash .dynsym .dynstr .rela.dyn 01 .init .plt .text .fini 02 .rodata .eh_frame_hdr .eh_frame 03 .init_array .fini_array .data.rel.ro .dynamic .got .got.plt .data= .bss 04 .dynamic 05 .note.gnu.build-id 06 .eh_frame_hdr 07 08 .init_array .fini_array .data.rel.ro .dynamic .got --- tools/musl-gcc.specs.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/musl-gcc.specs.sh b/tools/musl-gcc.specs.sh index 30492574..7e7ae562 100644 --- a/tools/musl-gcc.specs.sh +++ b/tools/musl-gcc.specs.sh @@ -8,7 +8,7 @@ cat <