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 18348 invoked from network); 6 Apr 2020 18:08:05 -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 18:08:05 -0000 Received: (qmail 17641 invoked by uid 550); 6 Apr 2020 18:08:03 -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 17618 invoked from network); 6 Apr 2020 18:08:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586196471; 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=XyWC470yPG8xZkXcyGGWX9n6WeKvbJ4oULGFh2Fces4=; b=Gxco8bdsI1wuvzsb1euzJF5wEMknNyHjbXQ/ZfnyEU2QBf5wsbNWaVOa+bi4IZk0rqpepo ZIJcIWqVfryhFGV1npz9NU4inPv33MEOsJvAWqudcqrDQX2MFjeQ/CR0k4js6yM7DBKrlG GJmrhGLSdzAATvPzECpkfzuXs/0fBbk= X-MC-Unique: jsdFo3DBM7y6hz4lQNkrvQ-1 From: harald@redhat.com To: musl@lists.openwall.com Cc: Harald Hoyer Date: Mon, 6 Apr 2020 20:07:38 +0200 Message-Id: <20200406180738.946894-1-harald@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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] V2 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(-) 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..72f5f487 --- a/tools/musl-gcc.specs.sh +++ b/tools/musl-gcc.specs.sh @@ -8,7 +8,7 @@ cat <