All of lore.kernel.org
 help / color / mirror / Atom feed
From: Glenn Washburn <development@efficientek.com>
To: Daniel Kiper <dkiper@net-space.pl>, grub-devel@gnu.org
Cc: Glenn Washburn <development@efficientek.com>
Subject: [PATCH] gdb: Add malloc and free symbols to kernel.exec to improve gdb functionality
Date: Wed,  2 Mar 2022 18:25:12 -0600	[thread overview]
Message-ID: <20220303002512.10596-1-development@efficientek.com> (raw)

Add linker flags when linking kernel.exec to have malloc and free point to
grub_malloc and grub_free respectively. Some gdb functionality depends on
gdb locating the symbols "malloc" and "free", such as dynamically creating
strings for arguments to injected function calls. A trivial example would
the gdb command 'p strlen("astring")'.

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
This should have been included in the gdb patch series I recently sent,
although its not required by nor requires any of those patches.

Glenn

---
 conf/Makefile.common | 1 +
 1 file changed, 1 insertion(+)

diff --git a/conf/Makefile.common b/conf/Makefile.common
index f0bb6e160a..069b428c1a 100644
--- a/conf/Makefile.common
+++ b/conf/Makefile.common
@@ -36,6 +36,7 @@ BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT)
 
 CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding
 LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC)
+LDFLAGS_KERNEL += -Wl,--defsym=malloc=grub_malloc -Wl,--defsym=free=grub_free
 CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
 CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
 STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx
-- 
2.27.0



             reply	other threads:[~2022-03-03  0:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03  0:25 Glenn Washburn [this message]
2022-03-09 15:49 ` [PATCH] gdb: Add malloc and free symbols to kernel.exec to improve gdb functionality Daniel Kiper
2022-03-09 20:25   ` Glenn Washburn
2022-03-10 23:09     ` Daniel Kiper
2022-03-15 13:23       ` Daniel Kiper
2022-03-15 19:36         ` Glenn Washburn
2022-03-16 20:59           ` Daniel Kiper
2022-03-18  6:57             ` Glenn Washburn
2022-03-22 16:54               ` Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220303002512.10596-1-development@efficientek.com \
    --to=development@efficientek.com \
    --cc=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.