This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: Fix empty sections with alignment
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Cc: amodra at bigpond dot net dot au
- Date: Mon, 26 Sep 2005 15:36:01 -0700
- Subject: PATCH: Fix empty sections with alignment
This patch
http://sourceware.org/ml/binutils/2005-09/msg00215.html
breaks empty sections with alignment. The patch here works for me.
H.J.
----
2005-09-26 H.J. Lu <hongjiu.lu@intel.com>
* ldlang.c (lang_size_sections_1): Process alignment addr_tree
later.
--- ld/ldlang.c.empty 2005-09-26 13:12:55.000000000 -0700
+++ ld/ldlang.c 2005-09-26 15:21:08.000000000 -0700
@@ -4044,7 +4044,9 @@ lang_size_sections_1
lang_output_section_statement_type *os;
os = &s->output_section_statement;
- if (os->addr_tree != NULL)
+ if (os->addr_tree != NULL
+ && !(os->addr_tree->type.node_class == etree_unary
+ && os->addr_tree->type.node_code == ALIGN_K))
{
os->processed = FALSE;
exp_fold_tree (os->addr_tree, bfd_abs_section_ptr, &dot);
@@ -4159,6 +4161,22 @@ lang_size_sections_1
os->name, (unsigned long) (newdot - savedot));
}
}
+ else if (os->addr_tree->type.node_class == etree_unary
+ && os->addr_tree->type.node_code == ALIGN_K)
+ {
+ newdot = dot;
+ os->processed = FALSE;
+ exp_fold_tree (os->addr_tree, bfd_abs_section_ptr,
+ &newdot);
+
+ if (!expld.result.valid_p
+ && expld.phase != lang_mark_phase_enum)
+ einfo (_("%F%S: non constant or forward reference"
+ " address expression for section %s\n"),
+ os->name);
+
+ newdot = expld.result.value + expld.result.section->vma;
+ }
/* The section starts here.
First, align to what the section needs. */