aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2005-07-28 20:08:15 +0000
committerDJ Delorie <dj@redhat.com>2005-07-28 20:08:15 +0000
commit8980686623b0a9734f23edbf48b6dc7a803cec8b (patch)
treeb21a8d48de92bf33803abc74bad376cc96571d4f
parentbec15d1f6a5e20b2fd3cb498745a696280c030ee (diff)
downloadgdb-8980686623b0a9734f23edbf48b6dc7a803cec8b.zip
gdb-8980686623b0a9734f23edbf48b6dc7a803cec8b.tar.gz
gdb-8980686623b0a9734f23edbf48b6dc7a803cec8b.tar.bz2
* ldlang.c (lang_output_section_statement_lookup_1): Don't cast a
unary & address operator, as that breaks GCC's strict aliasing rules.
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/ldlang.c7
2 files changed, 12 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 460fb39..d218b95 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2005-07-28 DJ Delorie <dj@redhat.com>
+
+ * ldlang.c (lang_output_section_statement_lookup_1): Don't cast a
+ unary & address operator, as that breaks GCC's strict aliasing
+ rules.
+
2005-07-25 Jan Hubicka <jh@suse.cz>
H.J. Lu <hongjiu.lu@intel.com>
diff --git a/ld/ldlang.c b/ld/ldlang.c
index dc8aa14..7cdb7c8 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -1010,6 +1010,7 @@ static lang_output_section_statement_type *
lang_output_section_statement_lookup_1 (const char *const name, int constraint)
{
lang_output_section_statement_type *lookup;
+ lang_output_section_statement_type **nextp;
lookup = lang_output_section_find_1 (name, constraint);
if (lookup == NULL)
@@ -1038,9 +1039,13 @@ lang_output_section_statement_lookup_1 (const char *const name, int constraint)
lookup->update_dot_tree = NULL;
lookup->phdrs = NULL;
+ /* GCC's strict aliasing rules prevent us from just casting the
+ address, so we store the pointer in a variable and cast that
+ instead. */
+ nextp = &lookup->next;
lang_statement_append (&lang_output_section_statement,
(lang_statement_union_type *) lookup,
- (lang_statement_union_type **) &lookup->next);
+ (lang_statement_union_type **) nextp);
}
return lookup;
}