From nobody Thu Mar 16 13:19:37 2023 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Pcnt24JPjz3y6gV for ; Thu, 16 Mar 2023 13:19:38 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Pcnt20lHVz3D0b for ; Thu, 16 Mar 2023 13:19:38 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678972778; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8M5UVuWafVdK9PoJ8U71mr4m34wxluIhLor8FYmiboc=; b=AoFn7J7YBSMRzi878h2zrT9F6/cNRLxQhtv7ixnDC8T9D49WW3xPkz5wcOAtrRa5W18CiY 60yKo0xrEIvwqamw0FHvpCUKp/gCYrK2ggdAbF+3jBNx2iki43PB51wYl2v/kf7X8B/b6d tE+RIlTC3ek3y5FjR9x3NVvkLz7AK/BFzhORXAAdqZc9jXtbtnQQIsfdKNxgokt+GQL2gT 2XcAkFIv/bDSUCz0jMWDR+VhRHhq0mK92tFjZT6LXlnMAavQq5X5NEefhYkZiuBLDCz8IS DjjsPz/6yOy/kNyr351g0j+/JZpzf1bmZiSeB6PhPONp40O/62ogy7lKJXI1Ag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678972778; a=rsa-sha256; cv=none; b=dK5oFufFp2SVzEnFnc0nGprsUx7Us9jD2Qbkxg3ZxOvPS4OxIwZhR9cJsNxWRWtuRW/HR7 EvoJ2B/pGYKsd+zY0lTaVdlKCf6cruy3xh3pC7pnDjKm+NawpDNX2SScXNGsvI5ogQ4bkR Bduqf69560RbHgiytReGqYf/pBzGazyKv0XRhGBjrwKbpJ+nuln1x/QpCPf19ljoBO3NW0 316hiGnTt3VjDx7tsPuWUzQFkNyyg+jLZNWVrlu10DpKVlNwlZmJoiUomTy1PDQMc+otaq vj2CzsF8oCOYKoJzPumtx+JXVv/wv4RGd+g693+ztnDmYzyjd09u8abbQ2XqDg== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Pcnt16vxSzl18 for ; Thu, 16 Mar 2023 13:19:37 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 32GDJbeH085848 for ; Thu, 16 Mar 2023 13:19:37 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 32GDJba8085847 for bugs@FreeBSD.org; Thu, 16 Mar 2023 13:19:37 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 269568] strip(1) creates an executable which crashes in ld-elf.so.1 Date: Thu, 16 Mar 2023 13:19:37 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: fernape@FreeBSD.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D269568 --- Comment #2 from Fernando Apestegu=C3=ADa --- More info: The problem is with the GNU_STACK segment. I edited the binary and changed = the vaddr and msize to match that of the original unstripped file and the resul= ting binary runs fine. Inspecting the sources of strip(1) I found the problem is in the copy_phdr function in segments.c in this specific code: if (seg->nsec > 0) { s =3D seg->v_sec[0]; seg->vaddr =3D s->vma; seg->paddr =3D s->lma; }=20=20=20 seg->fsz =3D seg->msz =3D 0; for (i =3D 0; i < seg->nsec; i++) { s =3D seg->v_sec[i]; seg->msz =3D s->vma + s->sz - seg->vaddr; if (s->type !=3D SHT_NOBITS) seg->fsz =3D s->off + s->sz - seg->off; } Changing that part so we actually copy the program header verbatim creates = an executable that doesn't crash. This kind of behavior seems to be similar to what llvm-strip and gnustrip do. To check this, using the objects created b= y a "make kernel" and "make buildworld" strip the full binary and check the original program header and the one from the stripped binary: STRIP_CMD=3Dllvm-strip for file in $(find . -name '*.full') do t=3D$(mktemp /tmp/tmp.XXXX) "${STRIP_CMD}" -o "${t}" "${file}" diff <(readelf -l "${file}") <(readelf -l "${t}") if [[ $? -eq 0 ]] then echo "Equal program header for ${file}" else echo "Different program header for ${file}" fi rm "${t}" done llvm-strip doesn't change the program header at all nor does GNU strip. But strip(1) in base changes it quite often (RELRO, INTERP and at least in jdup= es case GNU_STACK segments). --=20 You are receiving this mail because: You are the assignee for the bug.=