From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106862 invoked by alias); 27 Sep 2018 04:32:47 -0000 Mailing-List: contact gnu-gabi-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: gnu-gabi-owner@sourceware.org Received: (qmail 106808 invoked by uid 89); 27 Sep 2018 04:32:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.1 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,SPF_PASS autolearn=ham version=3.3.2 spammy=H*f:sk:CAORpzu, H*f:sk:MMN4-TZ, HTo:U*roland, H*i:sk:CAORpzu X-Spam-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-oi1-f171.google.com Received: from mail-oi1-f171.google.com (HELO mail-oi1-f171.google.com) (209.85.167.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Sep 2018 04:32:41 +0000 Received: by mail-oi1-f171.google.com with SMTP id d63-v6so1001106oic.12; Wed, 26 Sep 2018 21:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5lzdFNIbutH0R3T4lQqEKoxUAHfXYHgRddj16D9VBgA=; b=osVbZ1dRafrE2KoMsu4XvWXChMZYyXLlspX5tYJ1VYnqupENPWxOZGFfslBTp2FjY+ psVFuSLW5FoZNyW4e1fLwONxHmnO8nLiIR1vIQ61p+Wr6TI0JgHre2whCNuJkPqqim/F SvueQhmXvkKklTkVTelnV2LYJ/UNPARDjfivJEfEFFoK5lh/q9o0ntlHvAlf7N+nlZHt APaHPNS1JUsDxDIQ9yCLFxphza0LOHJ/6YW/eLIvUc6hQz6gYKRn03MlCyRooAwgGtVW Y2QON2a0/sw5801AQtj0w5j71FyCyJTlXH3NoY5jZL0YioOTtobccaZinhscuNLphLkL av8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=5lzdFNIbutH0R3T4lQqEKoxUAHfXYHgRddj16D9VBgA=; b=a9l+VTxcf3tcG9HSUsnEAtWLxZ/o2cCxZ6kqt8Tvdk/9Fe0hv625TecrD6Bpte+z/X EodCvcNCty+Y6pOVUeManjmQoA/hgCCwJPWrsPWwKYTLrBoDBDphMmQnoesPSCoxCH4g RZ/w3BF88pmei0WPFbNCk/Rpwk8MyVmkQ35Yw3pKbSTgqGCrwrHgf6V9iNqmWd7LVyvl Fo/YKmzi+QmnayX8MEEJI9Os5Zrog81mexvno4qLnZLie3ayhpKkSbpWrTUkTXMVvEww J98iVyAvPIBzENKkc+kw05HbrCGZfXyWpYCFZUArA2SlupoTTJOFxdVhT3xJR4pqNxlo S3iQ== X-Gm-Message-State: ABuFfohPrD2qTtyyTnBH/32Aby5KGUtLFBgUbb8SV+KRmZ/PFUwLfKno jvdItVwenP71wGKPccUaMUc9E59xlWt9yJhKuwQ= X-Google-Smtp-Source: ACcGV621g25LKlOf8vJ366yzB57teIkAcwtK7Cb/J9mt3JGnkHEnzJQc+QOWYQrBL3ySclSNsMPqP5DZRi0MtgAb4qI= X-Received: by 2002:aca:3cc3:: with SMTP id j186-v6mr2325168oia.128.1538022759796; Wed, 26 Sep 2018 21:32:39 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4a:4d44:0:0:0:0:0 with HTTP; Wed, 26 Sep 2018 21:31:59 -0700 (PDT) In-Reply-To: References: From: "H.J. Lu" Date: Mon, 01 Jan 2018 00:00:00 -0000 Message-ID: Subject: Re: RFC: Add SHT_GNU_PHDRS To: Roland McGrath Cc: Binutils , gnu-gabi@sourceware.org Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-q3/txt/msg00008.txt.bz2 On Wed, Sep 26, 2018 at 7:53 PM, Roland McGrath wrote: > Just put the rodata segment first. That's what lld does and it works great. Does it work with relro segment? Also rodata is always required: [hjl@gnu-cfl-1 ld]$ readelf -SWl tmpdir/pr23428 There are 13 section headers, starting at offset 0x2008: Section Headers: [Nr] Name Type Address Off Size ES Flg Lk Inf Al [ 0] NULL 0000000000000000 000000 000000 00 0 0 0 [ 1] .note.gnu.property NOTE 0000000000400120 000120 000020 00 A 0 0 8 [ 2] .text PROGBITS 0000000000401000 001000 00012d 00 AX 0 0 16 [ 3] .comment PROGBITS 0000000000000000 00112d 00002c 01 MS 0 0 1 [ 4] .debug_aranges PROGBITS 0000000000000000 001160 000060 00 0 0 16 [ 5] .debug_info PROGBITS 0000000000000000 0011c0 000482 00 0 0 1 [ 6] .debug_abbrev PROGBITS 0000000000000000 001642 00016d 00 0 0 1 [ 7] .debug_line PROGBITS 0000000000000000 0017af 000246 00 0 0 1 [ 8] .debug_frame PROGBITS 0000000000000000 0019f8 000040 00 0 0 8 [ 9] .debug_str PROGBITS 0000000000000000 001a38 000374 01 MS 0 0 1 [10] .symtab SYMTAB 0000000000000000 001db0 000198 18 11 11 8 [11] .strtab STRTAB 0000000000000000 001f48 000030 00 0 0 1 [12] .shstrtab STRTAB 0000000000000000 001f78 00008a 00 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), l (large), p (processor specific) Elf file type is EXEC (Executable file) Entry point 0x401000 There are 4 program headers, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000000 0x0000000000400000 0x0000000000400000 0x000140 0x000140 R 0x1000 LOAD 0x001000 0x0000000000401000 0x0000000000401000 0x00012d 0x00012d R E 0x1000 NOTE 0x000120 0x0000000000400120 0x0000000000400120 0x000020 0x000020 R 0x8 GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RWE 0x10 Section to Segment mapping: Segment Sections... 00 .note.gnu.property 01 .text 02 .note.gnu.property 03 [hjl@gnu-cfl-1 ld]$ ./tmpdir/pr23428 [hjl@gnu-cfl-1 ld]$ There is no rodata at all. > There is also the nacl layout that specifically addresses exactly this issue > for a platform that requires the code segment to have the lowest address, > but I don't think any other modern platform actually had such a requirement. > > On Wed, Sep 26, 2018, 14:54 H.J. Lu wrote: >> >> When -z separate-code is used to create executable, ld won't place any >> data in the code-only PT_LOAD segment. If there are no data sections >> placed before the code-only PT_LOAD segment, the program headers >> won't be mapped into any PT_LOAD segment. When the executable tries >> to access it (based on the program header address passed in AT_PHDR),ri >> it will lead to segfault. >> >> I am proposing >> >> #define SHT_GNU_PHDRS 0x6ffffff4 /* Dummy section for program header */ >> >> This is a special read-only SHF_ALLOC zero-size data section. It is the >> first output section, which will force a data PT_LOAD segment with program >> header before the code-only PT_LOAD segment, >> >> -- >> H.J. >> > -- > > > Thanks, > Roland -- H.J.