This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RE: Section (.sdata2) being omitted but SIZEOF(.sdata2) is not zero?
- From: Douglas Graham <douglas dot graham at ericsson dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Tue, 21 Jan 2014 13:54:04 +0000
- Subject: RE: Section (.sdata2) being omitted but SIZEOF(.sdata2) is not zero?
- Authentication-results: sourceware.org; auth=none
- References: <E36F5062C1BCFC48B8230995895548DF02C35784 at eusaamb109 dot ericsson dot se> <E36F5062C1BCFC48B8230995895548DF02C357A9 at eusaamb109 dot ericsson dot se> <20140119092749 dot GJ5390 at bubble dot grove dot modra dot org> <E36F5062C1BCFC48B8230995895548DF02C359DC at eusaamb109 dot ericsson dot se> <E36F5062C1BCFC48B8230995895548DF02C359F8 at eusaamb109 dot ericsson dot se> <20140120045856 dot GL5390 at bubble dot grove dot modra dot org> <E36F5062C1BCFC48B8230995895548DF02C36026 at eusaamb109 dot ericsson dot se> <20140121080319 dot GQ5390 at bubble dot grove dot modra dot org>
> Yes, I think you've nailed it (a nice debugging effort!). We strip sections early
> based on their sizes before relaxation. Your .sdata2 section is empty except
> for the padding, and the layout before relaxation just happens to need no
> padding. After relaxation you need padding but the section with the padding
> has gone. :-(
What are the chances we'd hit this! It only happens if the expression that computes the amount of padding necessary to pad out .sdata2 to end on a 4KB page boundary decides that no padding is necessary, so about 1 chance in 4096, or since .text is probably always 4-byte aligned, 1 chance in 1024. Must be our lucky day. No wonder I couldn't reproduce this in a simple test case (especially because my attempt at doing so did not use any library code with .eh_frame sections that change size). What I'm still not sure I understand is that we've seen this problem happen a few times over the last few months on a project with a fair amount of development ongoing. I could maybe see us maybe hitting this once, but then after a bit of churn, the chances of hitting it again shortly afterwards should be even slimmer.
So I guess a simple workaround is to add a ". = . + 4" inside .sdata2 before aligning, to force that section to always contain at least 4 bytes.
Thanks for your help,
Doug