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 31586 invoked from network); 7 Apr 2020 13:17:40 -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; 7 Apr 2020 13:17:40 -0000 Received: (qmail 24003 invoked by uid 550); 7 Apr 2020 13:17: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 23981 invoked from network); 7 Apr 2020 13:17:37 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586265445; 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=DMlGMd17Zy3yY1+RxOr/OQUTFIbXOqfdPdWFyhLL7bk=; b=Qc8z/4ixIj94TB6IV+OzKfYGOILSmUm/h0ZhPeo5tOs7JR2t7JQlLu/ibtpqcFnso97W5y 5rsRvD3yIOuHOLwc2BBnOHeoJTUqkW8yxg/K/rR6iSNkdzkb4lN7N4KrEx6OL8DKCnN6AI G2STUrxnxW/DlVvS6UMyWxjJAYbt+UM= X-MC-Unique: 9LY6iayjPbu8AwCLGxuSxg-1 From: harald@redhat.com To: musl@lists.openwall.com Cc: Harald Hoyer Date: Tue, 7 Apr 2020 15:17:07 +0200 Message-Id: <20200407131707.1220892-1-harald@redhat.com> In-Reply-To: <20200406220403.3moghw2llo34e6gh@gmail.com> References: <20200406220403.3moghw2llo34e6gh@gmail.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 | 6 +++--- 1 file changed, 3 insertions(+), 3 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..4d93626a --- a/tools/musl-gcc.specs.sh +++ b/tools/musl-gcc.specs.sh @@ -17,13 +17,13 @@ cat <