From owner-svn-src-all@freebsd.org Sun Sep 29 22:36:37 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 209EF12CB39 for ; Sun, 29 Sep 2019 22:36:37 +0000 (UTC) (envelope-from ray@ddteam.net) Received: from mail-ua1-x941.google.com (mail-ua1-x941.google.com [IPv6:2607:f8b0:4864:20::941]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46hL435ZTvz43yV for ; Sun, 29 Sep 2019 22:36:35 +0000 (UTC) (envelope-from ray@ddteam.net) Received: by mail-ua1-x941.google.com with SMTP id r19so3544073uap.9 for ; Sun, 29 Sep 2019 15:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ddteam-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=jCcBopMlywAwiHjAlH6j0GOMoJl6nc7sLL+4xxITBlM=; b=YIUMdt9/9XjKYXdcntJ/1FkadGNrG4lya8wWZ+DZUMRlxgLRiR5dNzVZAbUY/EvkYk LaSoDJZ4jcxiDwUi+/fGRqX2HpFbxO/14xLZWu7z+6jqjUkJAVfbbZnICzrf/yqRnO1L R801f66UsuEVGXX1adUvpK7aAPY1u3djmaHb19Qrs3KW+fqQCVLHLhFXKm8jQOL8fGmS sPrjjKN+KxvVozFx/bLaeHovcjpllNnGPqHh+BVvdvE/AdkoP7NcAZQby6DrRXr342R5 O6e+JpUnf9et/Wkf/l2ZH+rMsBmgeH9/V711e7IgF2Fq7cmxwB1T+AMqJxU3Ijgqx4jk 1Mpw== 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; bh=jCcBopMlywAwiHjAlH6j0GOMoJl6nc7sLL+4xxITBlM=; b=CLr1wCAOru+ouo1TgNoOL1KD5bgK4Jhdmm0cOKzhxeTkLqwtRI+gsKuyHOmQdBMSLs 0bR6WA0ENO7G2MxVeNjYR6dQ6BXM0dJQaOTDsurR+VV1ygcu7SM+C9eTCKwY9TaoTPd2 3eRUrQtmRY6kzX7TcGOpdM7Ld+oSGK/53YGCFCKScz8S51fuoTmPNMWXvLxpx2HYWenI x4VWXt0x0DNutpt46PHRNIcSD3fJweO6jsdt+9GE82jzblOaPKhF74meiH3oQTqjdEEi YLnRVv2TSdfXRtAM+uPTOZNnNz69V0eBG1RDARuGIgIlTtV7SDyhCTSsg72uuOyQzMnr zfOw== X-Gm-Message-State: APjAAAV0gCuNni6ZiiZk3uq1wPCuXvPBmn7wiXAiAbCD+LRhPbU6W6W+ sASuRZvPOanngHYa4bTmo2DePXjnkw2n4h8WTuigyg== X-Google-Smtp-Source: APXvYqz66fbvcYb1Zrzyxrphn1r1aFMDdGt5MQ63Bg8zNU0gLRdcVmvCH9i2i3nm2dwguv3OZTwZJCBuKRb7fTQS510= X-Received: by 2002:ab0:1c0b:: with SMTP id a11mr10069932uaj.65.1569796594751; Sun, 29 Sep 2019 15:36:34 -0700 (PDT) MIME-Version: 1.0 References: <201909292234.x8TMY260090143@repo.freebsd.org> In-Reply-To: <201909292234.x8TMY260090143@repo.freebsd.org> From: Oleksandr Rybalko Date: Mon, 30 Sep 2019 01:36:23 +0300 Message-ID: Subject: Re: svn commit: r352875 - head/contrib/elftoolchain/elfcopy To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-Rspamd-Queue-Id: 46hL435ZTvz43yV X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=ddteam-net.20150623.gappssmtp.com header.s=20150623 header.b=YIUMdt9/; dmarc=none; spf=softfail (mx1.freebsd.org: 2607:f8b0:4864:20::941 is neither permitted nor denied by domain of ray@ddteam.net) smtp.mailfrom=ray@ddteam.net X-Spamd-Result: default: False [-1.55 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.99)[-0.989,0]; R_DKIM_ALLOW(-0.20)[ddteam-net.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[svn-src-all@freebsd.org]; TO_DN_NONE(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; URI_COUNT_ODD(1.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[ddteam-net.20150623.gappssmtp.com:+]; MIME_BASE64_TEXT(0.10)[]; RCVD_IN_DNSWL_NONE(0.00)[1.4.9.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; DMARC_NA(0.00)[ddteam.net]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; IP_SCORE(-0.36)[ip: (3.00), ipnet: 2607:f8b0::/32(-2.58), asn: 15169(-2.17), country: US(-0.05)]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Sep 2019 22:36:37 -0000 Should be "Put sections into expected offset in binary format." Sorry. =D0=BF=D0=BD, 30 =D0=B2=D0=B5=D1=80. 2019 =D0=BE 01:34 Aleksandr Rybalko =D0=BF=D0=B8=D1=88=D0=B5: > Author: ray > Date: Sun Sep 29 22:34:01 2019 > New Revision: 352875 > URL: https://svnweb.freebsd.org/changeset/base/352875 > > Log: > ections into expected offset in binary format. > Calculate binary file offset using address field, bacause software know > only offset to known data, not where to load segment. > With that patch, kernel .data section can have any alignment/offset - > kernel boor fine. > > PR: 235391 > Reviewed by: markj > MFC after: 1 month > Differential Revision: D21827 > > Modified: > head/contrib/elftoolchain/elfcopy/binary.c > > Modified: head/contrib/elftoolchain/elfcopy/binary.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/contrib/elftoolchain/elfcopy/binary.c Sun Sep 29 20:44:13 2019 > (r352874) > +++ head/contrib/elftoolchain/elfcopy/binary.c Sun Sep 29 22:34:01 2019 > (r352875) > @@ -49,22 +49,23 @@ create_binary(int ifd, int ofd) > Elf *e; > Elf_Scn *scn; > Elf_Data *d; > + Elf64_Addr baseaddr; > GElf_Shdr sh; > - off_t base, off; > + off_t baseoff, off; > int elferr; > > if ((e =3D elf_begin(ifd, ELF_C_READ, NULL)) =3D=3D NULL) > errx(EXIT_FAILURE, "elf_begin() failed: %s", > elf_errmsg(-1)); > > - base =3D 0; > - if (lseek(ofd, base, SEEK_SET) < 0) > + baseoff =3D 0; > + if (lseek(ofd, baseoff, SEEK_SET) < 0) > err(EXIT_FAILURE, "lseek failed"); > > /* > * Find base offset in the first iteration. > */ > - base =3D -1; > + baseoff =3D -1; > scn =3D NULL; > while ((scn =3D elf_nextscn(e, scn)) !=3D NULL) { > if (gelf_getshdr(scn, &sh) =3D=3D NULL) { > @@ -76,14 +77,16 @@ create_binary(int ifd, int ofd) > sh.sh_type =3D=3D SHT_NOBITS || > sh.sh_size =3D=3D 0) > continue; > - if (base =3D=3D -1 || (off_t) sh.sh_offset < base) > - base =3D sh.sh_offset; > + if (baseoff =3D=3D -1 || (off_t) sh.sh_offset < baseoff) = { > + baseoff =3D sh.sh_offset; > + baseaddr =3D sh.sh_addr; > + } > } > elferr =3D elf_errno(); > if (elferr !=3D 0) > warnx("elf_nextscn failed: %s", elf_errmsg(elferr)); > > - if (base =3D=3D -1) > + if (baseoff =3D=3D -1) > return; > > /* > @@ -110,8 +113,8 @@ create_binary(int ifd, int ofd) > if (d->d_buf =3D=3D NULL || d->d_size =3D=3D 0) > continue; > > - /* lseek to section offset relative to `base'. */ > - off =3D sh.sh_offset - base; > + /* lseek to section offset relative to `baseaddr'. */ > + off =3D sh.sh_addr - baseaddr; > if (lseek(ofd, off, SEEK_SET) < 0) > err(EXIT_FAILURE, "lseek failed"); > > --=20 WBW ------- Rybalko Aleksandr