From 44f871628ccfcfd931f4619c60554f3bd6b57b8d Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Thu, 29 Apr 2021 11:43:53 +0200 Subject: x86: allow @size to also (sensibly) apply to sections So far this (counter-intuitively) produced the size as recorded in the (section) symbol. Obtain the section's size instead for section symbols. (I wonder whether STT_SECTION symbols couldn't properly hold the section's size in their st_size field, which in turn would likely mean the internal symbol would also have its size properly updated.) Note that this is not the same as the .sizeof.() pseudo-operator: @size yields the local file's contribution to a section, while .sizeof.() gets resolved by the linker to produce the final full section's size. As to the 3rd each of the expected output lines in the changed testcase: I can't find justification for zzz to come after yyy despite them being defined in the opposite order in source. Therefore I think it's better to permit both possible outcomes. --- gas/config/tc-i386.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gas/config') diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index bd2da65..9c544ee 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -14241,7 +14241,11 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) { /* Resolve size relocation against local symbol to size of the symbol plus addend. */ - valueT value = S_GET_SIZE (fixp->fx_addsy) + fixp->fx_offset; + valueT value = S_GET_SIZE (fixp->fx_addsy); + + if (symbol_get_bfdsym (fixp->fx_addsy)->flags & BSF_SECTION_SYM) + value = bfd_section_size (S_GET_SEGMENT (fixp->fx_addsy)); + value += fixp->fx_offset; if (fixp->fx_r_type == BFD_RELOC_SIZE32 && object_64bit && !fits_in_unsigned_long (value)) -- cgit v1.1