Created attachment 5265 [details] the reproduction case source file sample See the foo.S attached. When the code is compiled and linked (with a dummy main function), objdump -x shows that a faulty _test_nop size is calculated (in the example, 2 instead of 4). Removing the .section fixes the problem. This is causing some issues with GDB debugger in our architecture (Nios II). We've tested this in our architecture and with IA32.
gas should give an error with the testcase, since the expression given cannot be calculated at assembly time.
CVSROOT: /cvs/src Module name: src Changes by: amodra@sourceware.org 2011-02-25 07:48:51 Modified files: include/elf : ChangeLog internal.h Log message: PR 12519 * internal.h (ELF_SECTION_IN_SEGMENT_1): Don't match zero size sections at start or end of PT_DYNAMIC. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/elf/ChangeLog.diff?cvsroot=src&r1=1.410&r2=1.411 http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/elf/internal.h.diff?cvsroot=src&r1=1.26&r2=1.27
CVSROOT: /cvs/src Module name: src Branch: binutils-2_21-branch Changes by: amodra@sourceware.org 2011-02-25 07:50:37 Modified files: include/elf : ChangeLog internal.h Log message: PR 12519 * internal.h (ELF_SECTION_IN_SEGMENT_1): Don't match zero size sections at start or end of PT_DYNAMIC. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/elf/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.408&r2=1.408.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/elf/internal.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.26&r2=1.26.2.1
So, the syntax is invalid? Thanks for the quick reply
Yes, you cannot size a function over two sections like that.
CVSROOT: /cvs/src Module name: src Changes by: amodra@sourceware.org 2011-02-25 13:45:55 Modified files: gas : ChangeLog gas/config : obj-elf.c ld/testsuite : ChangeLog ld/testsuite/ld-mn10300: i135409-3.s ld/testsuite/ld-sh/sh64: stolib.s Log message: PR gas/12519 * config/obj-elf.c (elf_frob_symbol): Properly handle size expression. * ld-mn10300/i135409-3.s: Correct .size label reference. * ld-sh/sh64/stolib.s: Likewise. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/ChangeLog.diff?cvsroot=src&r1=1.4410&r2=1.4411 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/config/obj-elf.c.diff?cvsroot=src&r1=1.136&r2=1.137 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1369&r2=1.1370 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-mn10300/i135409-3.s.diff?cvsroot=src&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-sh/sh64/stolib.s.diff?cvsroot=src&r1=1.1&r2=1.2
CVSROOT: /cvs/src Module name: src Branch: binutils-2_21-branch Changes by: amodra@sourceware.org 2011-02-25 13:46:38 Modified files: gas : ChangeLog gas/config : obj-elf.c ld/testsuite : ChangeLog ld/testsuite/ld-mn10300: i135409-3.s ld/testsuite/ld-sh/sh64: stolib.s Log message: PR gas/12519 * config/obj-elf.c (elf_frob_symbol): Properly handle size expression. * ld-mn10300/i135409-3.s: Correct .size label reference. * ld-sh/sh64/stolib.s: Likewise. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.4320.2.16&r2=1.4320.2.17 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/config/obj-elf.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.133.2.3&r2=1.133.2.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1322.2.5&r2=1.1322.2.6 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-mn10300/i135409-3.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1&r2=1.1.12.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-sh/sh64/stolib.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1&r2=1.1.30.1
Fixed. Ignore commit messages in comment 2 and 3, which belong to PR12516.
CVSROOT: /cvs/src Module name: src Changes by: hjl@sourceware.org 2011-02-25 17:00:30 Modified files: gas/testsuite : ChangeLog gas/testsuite/gas/elf: elf.exp Added files: gas/testsuite/gas/elf: bad-size.d bad-size.err bad-size.s Log message: Add a testcase for PR gas/12519. 2011-02-25 H.J. Lu <hongjiu.lu@intel.com> PR gas/12519 * gas/elf/bad-size.d: New. * gas/elf/bad-size.err: Likewise. * gas/elf/bad-size.s: Likewise. * gas/elf/elf.exp: Run bad-size. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1853&r2=1.1854 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/bad-size.d.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/bad-size.err.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/bad-size.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/elf.exp.diff?cvsroot=src&r1=1.74&r2=1.75