[13/17] make MSYMBOL_VALUE_ADDRESS an rvalue
Tom Tromey
tromey@redhat.com
Wed Dec 14 21:30:00 GMT 2011
If a minimal symbol is inferior-independent, then we will have to
intercept calls to MSYMBOL_VALUE_ADDRESS and relocate the result on the
fly.
To make this simpler, I made MSYMBOL_VALUE_ADDRESS an rvalue and fixed
all the places that were using it as an lvalue. (The commit comment
says "lvalue" but that is because I had a momentary lapse of
vocabulary.)
Tom
>From a48b17330f48fddb58217578863785b3dd97e532 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Wed, 7 Dec 2011 13:01:55 -0700
Subject: [PATCH 13/18] make MSYMBOL_VALUE_ADDRESS an lvalue introduce raw
address introduce setter
* minsyms.c (prim_record_minimal_symbol_full): Use
SET_MSYMBOL_VALUE_ADDRESS.
(install_minimal_symbols): Use memset to initialize.
* objfiles.c (objfile_relocate1): Use SET_MSYMBOL_VALUE_ADDRESS.
* sh64-tdep.c (sh64_elf_make_msymbol_special): Use
SET_MSYMBOL_VALUE_ADDRESS.
* symtab.h (MSYMBOL_VALUE_ADDRESS): Make an rvalue.
(SET_MSYMBOL_VALUE_ADDRESS): New macro.
---
gdb/minsyms.c | 8 ++------
gdb/objfiles.c | 6 ++++--
gdb/sh64-tdep.c | 2 +-
gdb/symtab.h | 5 ++++-
4 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index e5d0b69..ff5113a 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -986,7 +986,7 @@ prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name,
MSYMBOL_SET_LANGUAGE (msymbol, language_auto);
MSYMBOL_SET_NAMES (msymbol, name, name_len, copy_name, objfile);
- MSYMBOL_VALUE_ADDRESS (msymbol) = address;
+ SET_MSYMBOL_VALUE_ADDRESS (msymbol, address);
MSYMBOL_SECTION (msymbol) = section;
MSYMBOL_SECTION_INDEX (msymbol) = 0;
@@ -1288,11 +1288,7 @@ install_minimal_symbols (struct objfile *objfile)
symbol count does *not* include this null symbol, which is why it
is indexed by mcount and not mcount-1. */
- MSYMBOL_LINKAGE_NAME (&msymbols[mcount]) = NULL;
- MSYMBOL_VALUE_ADDRESS (&msymbols[mcount]) = 0;
- MSYMBOL_TARGET_FLAG_1 (&msymbols[mcount]) = 0;
- MSYMBOL_TARGET_FLAG_2 (&msymbols[mcount]) = 0;
- MSYMBOL_SIZE (&msymbols[mcount]) = 0;
+ memset (&msymbols[mcount], 0, sizeof (struct minimal_symbol));
MSYMBOL_TYPE (&msymbols[mcount]) = mst_unknown;
MSYMBOL_SET_LANGUAGE (&msymbols[mcount], language_unknown);
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index dc81c4c..3d0d5ed 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -783,8 +783,10 @@ objfile_relocate1 (struct objfile *objfile,
ALL_OBJFILE_MSYMBOLS (objfile, msym)
if (MSYMBOL_SECTION (msym) >= 0)
- MSYMBOL_VALUE_ADDRESS (msym) += ANOFFSET (delta,
- MSYMBOL_SECTION (msym));
+ SET_MSYMBOL_VALUE_ADDRESS (msym,
+ MSYMBOL_VALUE_ADDRESS (msym)
+ + ANOFFSET (delta,
+ MSYMBOL_SECTION (msym)));
}
/* Relocating different sections by different amounts may cause the symbols
to be out of order. */
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 0ac4d10..28d0a78 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -225,7 +225,7 @@ sh64_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym)
if (((elf_symbol_type *)(sym))->internal_elf_sym.st_other == STO_SH5_ISA32)
{
MSYMBOL_TARGET_FLAG_1 (msym) = 1;
- MSYMBOL_VALUE_ADDRESS (msym) |= 1;
+ SET_MSYMBOL_VALUE_ADDRESS (msym, 1 | MSYMBOL_VALUE_ADDRESS (msym));
}
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index f3926e8..c5d9917 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -381,7 +381,10 @@ struct minimal_symbol
#define MSYMBOL_TYPE(msymbol) (msymbol)->type
#define MSYMBOL_VALUE(symbol) (symbol)->mginfo.value.ivalue
-#define MSYMBOL_VALUE_ADDRESS(symbol) (symbol)->mginfo.value.address
+#define MSYMBOL_VALUE_ADDRESS(symbol) ((symbol)->mginfo.value.address + 0)
+#define SET_MSYMBOL_VALUE_ADDRESS(symbol, addr) \
+ ((symbol)->mginfo.value.address) = (addr)
+
#define MSYMBOL_VALUE_BYTES(symbol) (symbol)->mginfo.value.bytes
#define MSYMBOL_BLOCK_VALUE(symbol) (symbol)->mginfo.value.block
#define MSYMBOL_VALUE_CHAIN(symbol) (symbol)->mginfo.value.chain
--
1.7.6.4
More information about the Gdb-patches
mailing list