From nobody Fri Apr 19 22:02:53 2024 X-Original-To: freebsd-questions@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 4VLpZl3qPzz5Hr1H for ; Fri, 19 Apr 2024 22:04:15 +0000 (UTC) (envelope-from kpn@neutralgood.org) Received: from gunsight1.neutralgood.org (gunsight1.neutralgood.org [206.196.19.100]) (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 (2048 bits) client-digest SHA256) (Client CN "gunsight1.neutralgood.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VLpZk695lz4FHb for ; Fri, 19 Apr 2024 22:04:14 +0000 (UTC) (envelope-from kpn@neutralgood.org) Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of kpn@neutralgood.org designates 206.196.19.100 as permitted sender) smtp.mailfrom=kpn@neutralgood.org Received: from gunsight1.NeutralGood.ORG (localhost [127.0.0.1]) by gunsight1.neutralgood.org (8.17.1/8.17.1) with ESMTPS id 43JM2riq032969 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 19 Apr 2024 18:02:53 -0400 (EDT) (envelope-from kpn@gunsight1.NeutralGood.ORG) Received: (from kpn@localhost) by gunsight1.NeutralGood.ORG (8.17.1/8.17.1/Submit) id 43JM2rPM032966; Fri, 19 Apr 2024 18:02:53 -0400 (EDT) (envelope-from kpn) Date: Fri, 19 Apr 2024 18:02:53 -0400 From: "Kevin P. Neal" To: Andrei Lascu Cc: freebsd-questions@freebsd.org Subject: Re: Questions about a symbol in `libc.so` Message-ID: References: <755e1ea7-6102-450a-bf64-bc717129e4ba@gmail.com> List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: freebsd-questions@freebsd.org Sender: owner-freebsd-questions@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <755e1ea7-6102-450a-bf64-bc717129e4ba@gmail.com> X-No-archive: Yes X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.16 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.86)[-0.861]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.10)[text/plain]; TAGGED_RCPT(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; ASN(0.00)[asn:13649, ipnet:206.196.0.0/19, country:US]; MIME_TRACE(0.00)[0:+]; FREEMAIL_TO(0.00)[gmail.com]; MID_RHS_MATCH_FROM(0.00)[]; R_DKIM_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DMARC_NA(0.00)[neutralgood.org]; RCVD_TLS_LAST(0.00)[]; MLMMJ_DEST(0.00)[freebsd-questions@freebsd.org]; FROM_HAS_DN(0.00)[] X-Rspamd-Queue-Id: 4VLpZk695lz4FHb On Thu, Apr 11, 2024 at 02:42:47PM +0100, Andrei Lascu wrote: > Hello again. Just to update my previous question, I did manage to eventually > figure out where the relocation was hidden. I was aware of a number of > relocation that seemed odd, and I put them on the side, thinking I might > either have to figure them later, or they might just be some artifact. Well, > the relocation I needed was hidden among them: > > Relocation section '.rela.dyn' at offset 0x2abf8 contains 2605 entries: >   Offset          Info           Type           Sym. Value    Sym. Name + > Addend > 0000001d6888  000000000403 R_AARCH64_RELATIV 13416c > 0000001d6890  000000000403 R_AARCH64_RELATIV 8b268 > 0000001d6898  000000000403 R_AARCH64_RELATIV 178108 > 0000001d68a0  000000000403 R_AARCH64_RELATIV 8b240 > 0000001d68a8  000000000403 R_AARCH64_RELATIV 15ac9c > 0000001d68b0  000000000403 R_AARCH64_RELATIV 49b29 > 0000001d68c0  000000000403 R_AARCH64_RELATIV 45bfe > > The reason I thought them odd was because they had no symbol attached to > them, just raw addressed. However, one of these offsets actually did match > what the system loader was relocating against my mystery `__sdidinit`. So > the solution was rather simple, ensure I relocate the addend into the > offset, as there is no symbol value here, and I am on my way. There are > still some odd issues here, like why are these relocations not referencing a > symbol, when seemingly they should, and why it seems these resolve via > `R_AARCH64_GLOB_DAT` at runtime, rather than via `R_AARCH64_RELATIVE` in > `/libexec/rtld-elf/aarch64/reloc.c`, but I think as long as I am making > progress, I'll let these questions get answered another time. I suggest the freebsd-hackers mailing list instead of freebsd-questions. This questions list has a lot of knowledgable people but my impression is this bunch tends to be higher in the software stack. You'll find more people on the -hackers list who can discuss, e.g, the loader and ELF and the like. -- Kevin P. Neal http://www.pobox.com/~kpn/ "14. Re-reading No. 13, I realize that it's quite possible I'm losing my mind. I'm glad that for the most part I'm not aware it's happening." -- from "20 things I'm thankful for": Fortune, Nov 29, 2004, page 230