From owner-svn-src-head@freebsd.org Tue Oct 30 21:24:04 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8224510F503E for ; Tue, 30 Oct 2018 21:24:04 +0000 (UTC) (envelope-from arichardson.kde@gmail.com) Received: from mail-yw1-f45.google.com (mail-yw1-f45.google.com [209.85.161.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 15FB17B08F for ; Tue, 30 Oct 2018 21:24:03 +0000 (UTC) (envelope-from arichardson.kde@gmail.com) Received: by mail-yw1-f45.google.com with SMTP id f192-v6so3960764ywh.7 for ; Tue, 30 Oct 2018 14:24:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9FQsFKmqZgc2PjGoXyxS+yCjcFUgRLJ0hlnVD8vZJ5E=; b=XEd8vhMqinrbHP2WeYmV29RqIXSiNMCh2Xg8e8zQKC8xfDrv8ZJXvm5TXkrKgC9PZ4 6OX1GNKR2148JDMo8Rzjpb1bfzvQI8/o9uFa/CwakBPuOie9Rn1ETECO/lhOcMmbO+t5 EJ5DOMgoplrShfrmifCPVHN2QdqBGc4Zjg3jIqfnloPjy0mhIODVbah+EhQ/9cfzss4K 6a5cZTIU7GN3+K6umMaAfyznYMLODPhRbr4wiJHYt//yA9N5e0S0L2hCq5gIRK2fmwpG TpgeNEFxMmic+i1V7OX6xKNReAz8ik8k2ZlC29x1VzyBeWIEQjBdRm1Vv90e2DjkpxSI OTSw== X-Gm-Message-State: AGRZ1gLsRnrQyXuPhQhsf7gWYCbtkKaUoeCsigRUBzRWr+w2C7Oe/aDo tIf5S9CqgOV+CvIY0r2KA9Nk1M/9M54= X-Google-Smtp-Source: AJdET5cWy9/9CpcPiUkxtEgNQvt54tDdbrh9fuj2ZG+kqbffnxd5pu28Be/bBRpGloLHXOZTZdx2yw== X-Received: by 2002:a0d:c306:: with SMTP id f6-v6mr450475ywd.356.1540934636953; Tue, 30 Oct 2018 14:23:56 -0700 (PDT) Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com. [209.85.219.176]) by smtp.gmail.com with ESMTPSA id 206-v6sm3268021ywy.104.2018.10.30.14.23.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 14:23:56 -0700 (PDT) Received: by mail-yb1-f176.google.com with SMTP id i78-v6so5712212ybg.0 for ; Tue, 30 Oct 2018 14:23:56 -0700 (PDT) X-Received: by 2002:a25:888d:: with SMTP id d13-v6mr476470ybl.74.1540934636264; Tue, 30 Oct 2018 14:23:56 -0700 (PDT) MIME-Version: 1.0 References: <7DC6D9C4-C153-4BCE-851C-22C890AB0D73@yahoo.com> In-Reply-To: <7DC6D9C4-C153-4BCE-851C-22C890AB0D73@yahoo.com> From: Alexander Richardson Date: Tue, 30 Oct 2018 21:23:45 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r339876 - head/libexec/rtld-elf To: marklmi26-fbsd@yahoo.com Cc: svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Oct 2018 21:24:04 -0000 On Tue, 30 Oct 2018 at 18:19, Mark Millard wrote: > > Alexander Richardson arichardson at freebsd.org wrote on > Tue Oct 30 15:33:00 UTC 2018 : > > > On Tue, 30 Oct 2018 at 10:17, Michael Tuexen > > wrote: > > > > > > > On 29. Oct 2018, at 22:08, Alex Richardson wrote: > > > > > > > > Author: arichardson > > > > Date: Mon Oct 29 21:08:02 2018 > > > > New Revision: 339876 > > > > URL: https://svnweb.freebsd.org/changeset/base/339876 > > > > > > > > Log: > > > > rtld: set obj->textsize correctly > > > > > > > > With lld-generated binaries the first PT_LOAD will usually be a read-only > > > > segment unless you pass --no-rosegment. For those binaries the textsize is > > > > determined by the next PT_LOAD. To allow both LLD and bfd 2.17 binaries to > > > > be parsed correctly use the end of the last PT_LOAD that is marked as > > > > executable instead. > > > > > > > > I noticed that the value was wrong while adding some debug prints for some rtld > > > > changes for CHERI binaries. `obj->textsize` only seems to be used by PPC so the > > > > effect is untested. However, the value before was definitely wrong and the new > > > > result matches the phdrs. > > > I build kernel and world with a revision later than this on a PPC. Buildword > > > ends up with a world where almost all binaries are segfaulting.... Especially gdb > > > (but svn, ls or so all segfault). > > > > > > Best regards > > > Michael > > > > This is rather surprising since if anything the range of the icache > > flush should increase rather than decrease after this change. > > > > I can only see this causing a behaviour change if we actually need to > > flush more than just the executable segments. > > Is it possible that some binary/library contains a non-executable > > segment as the first PT_LOAD? > > Or is there some linker script that adds custom PHDRS? > > The following is based on using devel/powerpc64-xtoolchain-gcc > to buildworld buildkernel on/for powerpc64. (I experiment with > using fairly modern tools to target powerpc64 and powerpc.) > The build context is head -r339076 based, both for what > did the build and for what it was building. > > I report from both elfdump and objdump output > because each seems to have some oddities in what > it outputs. > > I start with elfdump (which leaves sh_flags blank > and shows a section header with sh_name empty > that objdump does not list at all): > > # elfdump -pc /bin/ls | less > > program header: > > entry: 0 > p_type: PT_PHDR > p_offset: 64 > p_vaddr: 0x10000040 > p_paddr: 0x10000040 > p_filesz: 392 > p_memsz: 392 > p_flags: PF_R > p_align: 8 > > entry: 1 > p_type: PT_INTERP > p_offset: 456 > p_vaddr: 0x100001c8 > p_paddr: 0x100001c8 > p_filesz: 21 > p_memsz: 21 > p_flags: PF_R > p_align: 1 > > entry: 2 > p_type: PT_LOAD > p_offset: 0 > p_vaddr: 0x10000000 > p_paddr: 0x10000000 > p_filesz: 37132 > p_memsz: 37132 > p_flags: PF_X|PF_R > p_align: 65536 > > entry: 3 > p_type: PT_LOAD > p_offset: 37136 > p_vaddr: 0x10019110 > p_paddr: 0x10019110 > p_filesz: 3808 > p_memsz: 4328 > p_flags: PF_W|PF_R > p_align: 65536 > > entry: 4 > p_type: PT_DYNAMIC > p_offset: 37176 > p_vaddr: 0x10019138 > p_paddr: 0x10019138 > p_filesz: 448 > p_memsz: 448 > p_flags: PF_W|PF_R > p_align: 8 > > entry: 5 > p_type: PT_NOTE > p_offset: 480 > p_vaddr: 0x100001e0 > p_paddr: 0x100001e0 > p_filesz: 48 > p_memsz: 48 > p_flags: PF_R > p_align: 4 > > entry: 6 > p_type: PT_LOAD > p_offset: 0 > p_vaddr: 0 > p_paddr: 0 > p_filesz: 0 > p_memsz: 0 > p_flags: PF_W|PF_R > p_align: 16 > > section header: > > entry: 0 > sh_name: > sh_type: SHT_NULL > sh_flags: > sh_addr: 0 > sh_offset: 0 > sh_size: 0 > sh_link: 0 > sh_info: 0 > sh_addralign: 0 > sh_entsize: 0 > > entry: 1 > sh_name: .interp > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0x100001c8 > sh_offset: 456 > sh_size: 21 > sh_link: 0 > sh_info: 0 > sh_addralign: 1 > sh_entsize: 0 > > entry: 2 > sh_name: .note.tag > sh_type: SHT_NOTE > sh_flags: > sh_addr: 0x100001e0 > sh_offset: 480 > sh_size: 48 > sh_link: 0 > sh_info: 0 > sh_addralign: 4 > sh_entsize: 0 > > entry: 3 > sh_name: .hash > sh_type: SHT_HASH > sh_flags: > sh_addr: 0x10000210 > sh_offset: 528 > sh_size: 636 > sh_link: 4 > sh_info: 0 > sh_addralign: 8 > sh_entsize: 4 > > entry: 4 > sh_name: .dynsym > sh_type: SHT_DYNSYM > sh_flags: > sh_addr: 0x10000490 > sh_offset: 1168 > sh_size: 2160 > sh_link: 5 > sh_info: 1 > sh_addralign: 8 > sh_entsize: 24 > > entry: 5 > sh_name: .dynstr > sh_type: SHT_STRTAB > sh_flags: > sh_addr: 0x10000d00 > sh_offset: 3328 > sh_size: 858 > sh_link: 0 > sh_info: 0 > sh_addralign: 1 > sh_entsize: 0 > > entry: 6 > sh_name: .gnu.version > sh_type: SHT_SUNW(GNU)_versym > sh_flags: > sh_addr: 0x1000105a > sh_offset: 4186 > sh_size: 180 > sh_link: 4 > sh_info: 0 > sh_addralign: 2 > sh_entsize: 2 > > entry: 7 > sh_name: .gnu.version_r > sh_type: SHT_SUNW(GNU)_verneed > sh_flags: > sh_addr: 0x10001110 > sh_offset: 4368 > sh_size: 80 > sh_link: 5 > sh_info: 1 > sh_addralign: 8 > sh_entsize: 0 > > entry: 8 > sh_name: .rela.dyn > sh_type: SHT_RELA > sh_flags: > sh_addr: 0x10001160 > sh_offset: 4448 > sh_size: 408 > sh_link: 4 > sh_info: 0 > sh_addralign: 8 > sh_entsize: 24 > > entry: 9 > sh_name: .rela.plt > sh_type: SHT_RELA > sh_flags: > sh_addr: 0x100012f8 > sh_offset: 4856 > sh_size: 1776 > sh_link: 4 > sh_info: 21 > sh_addralign: 8 > sh_entsize: 24 > > entry: 10 > sh_name: .init > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0x100019f0 > sh_offset: 6640 > sh_size: 44 > sh_link: 0 > sh_info: 0 > sh_addralign: 16 > sh_entsize: 0 > > entry: 11 > sh_name: .text > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0x10001a20 > sh_offset: 6688 > sh_size: 29188 > sh_link: 0 > sh_info: 0 > sh_addralign: 32 > sh_entsize: 0 > > entry: 12 > sh_name: .fini > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0x10008c30 > sh_offset: 35888 > sh_size: 36 > sh_link: 0 > sh_info: 0 > sh_addralign: 16 > sh_entsize: 0 > > entry: 13 > sh_name: .rodata > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0x10008c58 > sh_offset: 35928 > sh_size: 1200 > sh_link: 0 > sh_info: 0 > sh_addralign: 8 > sh_entsize: 0 > > entry: 14 > sh_name: .eh_frame > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0x10009108 > sh_offset: 37128 > sh_size: 4 > sh_link: 0 > sh_info: 0 > sh_addralign: 4 > sh_entsize: 0 > > entry: 15 > sh_name: .ctors > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0x10019110 > sh_offset: 37136 > sh_size: 16 > sh_link: 0 > sh_info: 0 > sh_addralign: 8 > sh_entsize: 0 > > entry: 16 > sh_name: .dtors > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0x10019120 > sh_offset: 37152 > sh_size: 16 > sh_link: 0 > sh_info: 0 > sh_addralign: 8 > sh_entsize: 0 > > entry: 17 > sh_name: .jcr > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0x10019130 > sh_offset: 37168 > sh_size: 8 > sh_link: 0 > sh_info: 0 > sh_addralign: 8 > sh_entsize: 0 > > entry: 18 > sh_name: .dynamic > sh_type: SHT_DYNAMIC > sh_flags: > sh_addr: 0x10019138 > sh_offset: 37176 > sh_size: 448 > sh_link: 5 > sh_info: 0 > sh_addralign: 8 > sh_entsize: 16 > > entry: 19 > sh_name: .opd > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0x100192f8 > sh_offset: 37624 > sh_size: 1128 > sh_link: 0 > sh_info: 0 > sh_addralign: 8 > sh_entsize: 0 > > entry: 20 > sh_name: .got > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0x10019800 > sh_offset: 38912 > sh_size: 152 > sh_link: 0 > sh_info: 0 > sh_addralign: 256 > sh_entsize: 8 > > entry: 21 > sh_name: .plt > sh_type: SHT_NOBITS > sh_flags: > sh_addr: 0x10019898 > sh_offset: 39064 > sh_size: 1800 > sh_link: 0 > sh_info: 0 > sh_addralign: 8 > sh_entsize: 24 > > entry: 22 > sh_name: .data > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0x10019fa0 > sh_offset: 40864 > sh_size: 80 > sh_link: 0 > sh_info: 0 > sh_addralign: 8 > sh_entsize: 0 > > entry: 23 > sh_name: .bss > sh_type: SHT_NOBITS > sh_flags: > sh_addr: 0x10019ff0 > sh_offset: 40944 > sh_size: 520 > sh_link: 0 > sh_info: 0 > sh_addralign: 8 > sh_entsize: 0 > > entry: 24 > sh_name: .comment > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0 > sh_offset: 40944 > sh_size: 693 > sh_link: 0 > sh_info: 0 > sh_addralign: 1 > sh_entsize: 1 > > entry: 25 > sh_name: .gnu_debuglink > sh_type: SHT_PROGBITS > sh_flags: > sh_addr: 0 > sh_offset: 41640 > sh_size: 16 > sh_link: 0 > sh_info: 0 > sh_addralign: 4 > sh_entsize: 0 > > entry: 26 > sh_name: .shstrtab > sh_type: SHT_STRTAB > sh_flags: > sh_addr: 0 > sh_offset: 41656 > sh_size: 208 > sh_link: 0 > sh_info: 0 > sh_addralign: 1 > sh_entsize: 0 > > As for objdump on the same file (section > one less than elfdump listed, no empty sh_name > section listed): > > # objdump -ph /bin/ls | less > > /bin/ls: file format elf64-powerpc-freebsd > > Program Header: > PHDR off 0x0000000000000040 vaddr 0x0000000010000040 paddr 0x0000000010000040 align 2**3 > filesz 0x0000000000000188 memsz 0x0000000000000188 flags r-- > INTERP off 0x00000000000001c8 vaddr 0x00000000100001c8 paddr 0x00000000100001c8 align 2**0 > filesz 0x0000000000000015 memsz 0x0000000000000015 flags r-- > LOAD off 0x0000000000000000 vaddr 0x0000000010000000 paddr 0x0000000010000000 align 2**16 > filesz 0x000000000000910c memsz 0x000000000000910c flags r-x > LOAD off 0x0000000000009110 vaddr 0x0000000010019110 paddr 0x0000000010019110 align 2**16 > filesz 0x0000000000000ee0 memsz 0x00000000000010e8 flags rw- > DYNAMIC off 0x0000000000009138 vaddr 0x0000000010019138 paddr 0x0000000010019138 align 2**3 > filesz 0x00000000000001c0 memsz 0x00000000000001c0 flags rw- > NOTE off 0x00000000000001e0 vaddr 0x00000000100001e0 paddr 0x00000000100001e0 align 2**2 > filesz 0x0000000000000030 memsz 0x0000000000000030 flags r-- > STACK off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**4 > filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw- > > Dynamic Section: > NEEDED libutil.so.9 > NEEDED libncursesw.so.8 > NEEDED libc.so.7 > INIT 0x0000000010019328 > FINI 0x0000000010019340 > HASH 0x0000000010000210 > STRTAB 0x0000000010000d00 > SYMTAB 0x0000000010000490 > STRSZ 0x000000000000035a > SYMENT 0x0000000000000018 > DEBUG 0x0000000000000000 > PLTGOT 0x0000000010019898 > PLTRELSZ 0x00000000000006f0 > PLTREL 0x0000000000000007 > JMPREL 0x00000000100012f8 > 0x70000000 0x00000000100089b4 > RELA 0x0000000010001160 > RELASZ 0x0000000000000198 > RELAENT 0x0000000000000018 > VERNEED 0x0000000010001110 > VERNEEDNUM 0x0000000000000001 > VERSYM 0x000000001000105a > > Version References: > required from libc.so.7: > 0x077a28b3 0x00 05 FBSD_1.3 > 0x077a28b1 0x00 04 FBSD_1.1 > 0x077a28b5 0x00 03 FBSD_1.5 > 0x077a28b0 0x00 02 FBSD_1.0 > private flags = 0x1: [abiv1] > > Sections: > Idx Name Size VMA LMA File off Algn > 0 .interp 00000015 00000000100001c8 00000000100001c8 000001c8 2**0 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 1 .note.tag 00000030 00000000100001e0 00000000100001e0 000001e0 2**2 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 2 .hash 0000027c 0000000010000210 0000000010000210 00000210 2**3 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 3 .dynsym 00000870 0000000010000490 0000000010000490 00000490 2**3 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 4 .dynstr 0000035a 0000000010000d00 0000000010000d00 00000d00 2**0 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 5 .gnu.version 000000b4 000000001000105a 000000001000105a 0000105a 2**1 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 6 .gnu.version_r 00000050 0000000010001110 0000000010001110 00001110 2**3 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 7 .rela.dyn 00000198 0000000010001160 0000000010001160 00001160 2**3 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 8 .rela.plt 000006f0 00000000100012f8 00000000100012f8 000012f8 2**3 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 9 .init 0000002c 00000000100019f0 00000000100019f0 000019f0 2**4 > CONTENTS, ALLOC, LOAD, READONLY, CODE > 10 .text 00007204 0000000010001a20 0000000010001a20 00001a20 2**5 > CONTENTS, ALLOC, LOAD, READONLY, CODE > 11 .fini 00000024 0000000010008c30 0000000010008c30 00008c30 2**4 > CONTENTS, ALLOC, LOAD, READONLY, CODE > 12 .rodata 000004b0 0000000010008c58 0000000010008c58 00008c58 2**3 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 13 .eh_frame 00000004 0000000010009108 0000000010009108 00009108 2**2 > CONTENTS, ALLOC, LOAD, READONLY, DATA > 14 .ctors 00000010 0000000010019110 0000000010019110 00009110 2**3 > CONTENTS, ALLOC, LOAD, DATA > 15 .dtors 00000010 0000000010019120 0000000010019120 00009120 2**3 > CONTENTS, ALLOC, LOAD, DATA > 16 .jcr 00000008 0000000010019130 0000000010019130 00009130 2**3 > CONTENTS, ALLOC, LOAD, DATA > 17 .dynamic 000001c0 0000000010019138 0000000010019138 00009138 2**3 > CONTENTS, ALLOC, LOAD, DATA > 18 .opd 00000468 00000000100192f8 00000000100192f8 000092f8 2**3 > CONTENTS, ALLOC, LOAD, DATA > 19 .got 00000098 0000000010019800 0000000010019800 00009800 2**8 > CONTENTS, ALLOC, LOAD, DATA > 20 .plt 00000708 0000000010019898 0000000010019898 00009898 2**3 > ALLOC > 21 .data 00000050 0000000010019fa0 0000000010019fa0 00009fa0 2**3 > CONTENTS, ALLOC, LOAD, DATA > 22 .bss 00000208 0000000010019ff0 0000000010019ff0 00009ff0 2**3 > ALLOC > 23 .comment 000002b5 0000000000000000 0000000000000000 00009ff0 2**0 > CONTENTS, READONLY > 24 .gnu_debuglink 00000010 0000000000000000 0000000000000000 0000a2a8 2**2 > CONTENTS, READONLY > > The first PT_LOAD is also executable so there will be no be behaviour change. It must be one of the library dependencies that is different. The difference in section headers output doesn't matter here since all that RTLD looks at is the PHDRS. Alex