From patchwork Wed Mar 6 19:22:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Rodriguez Reboredo X-Patchwork-Id: 86893 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F9283857C4F for ; Wed, 6 Mar 2024 19:23:12 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id C49113858D34 for ; Wed, 6 Mar 2024 19:23:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C49113858D34 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C49113858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1031 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709752982; cv=none; b=mj04dV1V7UY0vQaaSoL1Cr/ck33ErbHGZ0vLQgcNeWd4cI/DKq4c6cHETkkYmab0RJXcbC08S7wtZLNyNKCg73jVwIJCQwBLYoouR6UvWH0s0gK2zi5zwXIw9oiaBZNrt1g9EUPhOojPnjHQ/VnxE9L46LKk+RsbKwI/FJKLi2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709752982; c=relaxed/simple; bh=BWmgzIa6XMmVcJcGFOoUjDkqnZWdy7TQM0HXzYNbcnA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=opgBt44mv73Mu1xBfeeyp37JtR9eVDB4I+zB0p53tLWgBZYsFEkmDpznec1BkpgE+O0W20nFuX/oICIrYxHTqcG6g+Yt/650zyu+EwadrSkhkOIWR3MqFwu1suzSauF5cSj9+/XsFNekop2otLcV888k7xfs3YIafFzfwi/BGnc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-29b6f82125dso1325452a91.1 for ; Wed, 06 Mar 2024 11:23:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709752979; x=1710357779; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=BYqj17xWyIrPgYaJHlpo7UpAWJlyi+zNf+V8g/gswl0=; b=SqBpWZbfxQ+1b8JN7bcD0G1tDW7Xifk1VnBlAM1bmFiESAN9NXSY8ctyXVoQdFiKWA 0+SNSMYZ5I1102etBBj13Vvq5BqY9YLfcSIOsBZoaJtP0PFeyvU4apMJw7PHwueXJ8QT DRXhvfg+R3Hx9+9OBedomaPSaCgiE0tsUpDxZ4ORTW+UORJGvVW0Ux9T5y46lARE9GyP ZUoOdNN5btoyKigTYLQ3izY6lR5baRNEs3ehk9l4p1NW9ViEn4rQ1/1+SIXZPpT4UDub LHZSVMy+18qx2jYZQJEXemWAxvY8ExLZUEBSG6K2kO1ALM0pPPI7xdKqtlYl65jcAqjl kZZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709752979; x=1710357779; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BYqj17xWyIrPgYaJHlpo7UpAWJlyi+zNf+V8g/gswl0=; b=BYaWI4JSAfqVcPDKzz41230k1a03QKWfxEJHmWq3HJBaTuVLPVxpQqQGoV7TA5Vc29 73KmEJiUnC6k0OSrEo7t5dSD+gQwb1jW0cnN2TxgyAFyYybL3qTPSVK9s3XtUdROQmzy EjVn3j1Rnw9CPLcMx2Zsf72fQN051cApfImdgMGifK+aqAjlY8JrYBAd9W5AaVk/KHhN uo4qlMIotvw9MfYKkq3vPmj5CYYpUxAIvo8RuuiyQGvmatvFsCTl9VKX6TKhaqtoLlSO VLYZ/8OU2xc6l/kC0YIn6ir1TgBvInKGCJPEESV5WwyXWyMrc87dSR3ClvWoH4Km4XFq 2Sxg== X-Gm-Message-State: AOJu0YzVDMNJUk2DRegNewxbtOV1RfLRZugEgYniJrt00eAidt1Iik8T oYdilpVxMmkHDWwEM+QZvkB8TnZeOIUbvBlfLNOF9Z70vqcSgIWZae/P1c5I X-Google-Smtp-Source: AGHT+IFzRiwek22DHdccQc39GbfFFZD9p9QZtjVGdEr0kHMSpAc5Q65iq5EN2AnHYBwE0GDAbAYqyg== X-Received: by 2002:a17:90a:da05:b0:29a:9d38:9e2b with SMTP id e5-20020a17090ada0500b0029a9d389e2bmr11463682pjv.47.1709752978881; Wed, 06 Mar 2024 11:22:58 -0800 (PST) Received: from tx3000mach.io (static.220.238.itcsa.net. [190.15.220.238]) by smtp.gmail.com with ESMTPSA id e15-20020a17090301cf00b001db43f3629dsm12978491plh.140.2024.03.06.11.22.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 11:22:58 -0800 (PST) From: Martin Rodriguez Reboredo To: elfutils-devel@sourceware.org Subject: [PATCH] Getter and setter for Dwfl's offline_next_address Date: Wed, 6 Mar 2024 16:22:49 -0300 Message-ID: <20240306192249.242130-1-yakoyoku@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Added new functions dwfl_get_offline_next_address and dwfl_set_offline_next_address which will get plus set said field from the Dwfl struct. This is a requirement for listing functions from their addresses when using libdwfl offline, otherwise wrong symbols are going to be returned. Signed-off-by: Martin Rodriguez Reboredo --- This is meant to replace a patch that only had the setter [1]. Link: https://sourceware.org/pipermail/elfutils-devel/2024q1/006874.html [1] libdwfl/libdwfl.h | 6 +++++ libdwfl/offline.c | 12 ++++++++++ tests/dwfl-offline-address.c | 43 ++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 tests/dwfl-offline-address.c diff --git a/libdwfl/libdwfl.h b/libdwfl/libdwfl.h index 49ad6664..08aa61c4 100644 --- a/libdwfl/libdwfl.h +++ b/libdwfl/libdwfl.h @@ -109,6 +109,12 @@ extern int dwfl_errno (void); extern const char *dwfl_errmsg (int err); +/* Get the next offline address. */ +extern GElf_Addr dwfl_get_offline_next_address (Dwfl *dwfl); + +/* Set the next offline address. */ +extern void dwfl_set_offline_next_address (Dwfl *dwfl, GElf_Addr addr); + /* Start reporting the current set of segments and modules to the library. All existing segments are wiped. Existing modules are marked to be deleted, and will not be found via dwfl_addrmodule et al if they are not diff --git a/libdwfl/offline.c b/libdwfl/offline.c index e9ab0cc1..ca770fac 100644 --- a/libdwfl/offline.c +++ b/libdwfl/offline.c @@ -35,6 +35,18 @@ #include "libdwflP.h" #include +GElf_Addr +dwfl_get_offline_next_address (Dwfl *dwfl) +{ + return dwfl->offline_next_address; +} + +void +dwfl_set_offline_next_address (Dwfl *dwfl, GElf_Addr addr) +{ + dwfl->offline_next_address = addr; +} + /* Since dwfl_report_elf lays out the sections already, this will only be called when the section headers of the debuginfo file are being consulted instead, or for the section placed at 0. With binutils diff --git a/tests/dwfl-offline-address.c b/tests/dwfl-offline-address.c new file mode 100644 index 00000000..9a33b95a --- /dev/null +++ b/tests/dwfl-offline-address.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include ELFUTILS_HEADER(dwfl) +#include +#include "system.h" + +#define OFFLINE_REDZONE 0x10000 + +static const Dwfl_Callbacks offline_callbacks = + { + .find_debuginfo = INTUSE(dwfl_standard_find_debuginfo), + .section_address = INTUSE(dwfl_offline_section_address), + }; + +int +main (int argc, char **argv) +{ + Dwfl *dwfl = dwfl_begin (&offline_callbacks); + assert (dwfl != NULL); + + if (dwfl_get_offline_next_address (dwfl) != OFFLINE_REDZONE) + { + dwfl_end (dwfl); + return 1; + } + + int result = 0; + dwfl_set_offline_next_address (dwfl, 0); + if (dwfl_get_offline_next_address (dwfl) != 0) + result = 1; + + dwfl_end (dwfl); + + return result; +}