From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7E687381DCF8; Wed, 11 Mar 2020 06:52:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E687381DCF8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1583909557; bh=70MrWn4J37D66v+eKqND0SwOAueEn3n8HkvQXR0pwUk=; h=From:To:Subject:Date:From; b=K/kik/P5FgYlIkPzEQLiYvNZ29sc1Hu0PqPZyP3fzGDvUDbHQo49K5zuL3cc5244F h+s9oaICdLwwKlUFp6WPg0WZVw65w3RaO2Yi4YpmA508hYoP1mrLEFsBBT7qrWvNsO 8JlyTA4pDDacqrtN42tTR5VMY6XM1rdN/5Wwf2zY= From: "casner at acm dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/94134] New: pdp11-aout puts initial variable into .text section rather than .data Date: Wed, 11 Mar 2020 06:52:37 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: casner at acm dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2020 06:52:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94134 Bug ID: 94134 Summary: pdp11-aout puts initial variable into .text section rather than .data Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: casner at acm dot org Target Milestone: --- The assembler output for a C program compiled for the pdp11-aout target beg= ins with a .text directive. If that program begins with a variable that is not initialized to a nonzero value, that variable will be left if the .text sec= tion rather than being allocated to the .data section. If the first variable is initialized to a nonzero value, then a .data directive is inserted after the .text directive to switch sections. This bug matters for formats where the text section is read-only or with split instruction and data spaces. I selected component target, but I don't know if this problem is specific to the pdp11-aout target. Here is a simple example showing this problem: Command: pdp11-aout-gcc -ffreestanding -nostdlib -S -o zero.s zero.c static int zero =3D 0; static int one =3D 1; int main() {} .text .even _zero: .=3D.+ 02 .data .even _one: .word 01 .text .even .globl _main _main: setd seti mov r5,-(sp) mov sp,r5 jsr pc,___main nop mov (sp)+,r5 rts pc If the first variable is initialized to a nonzero value, the output is corr= ect: Command: pdp11-aout-gcc -ffreestanding -nostdlib -S -o one.s one.c static int one =3D 1; static int zero =3D 0; int main() {} .text .data .even _one: .word 01 .even _zero: .=3D.+ 02 .text .even .globl _main _main: setd seti mov r5,-(sp) mov sp,r5 jsr pc,___main nop mov (sp)+,r5 rts pc My environment is a macOS host and pdp11-aout target. GNU C17 (GCC) version 10.0.1 20200303 (experimental) (pdp11-aout) compiled by GNU C version 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.17), GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.= 1.0, isl version isl-0.20-GMP Configured with: ../configure --target=3Dpdp11-aout --prefix=3D/usr/local --disable-libstdc++-v3 --disable-libssp --disable-libgfortran --disable-lib= objc --disable-libbacktrace --with-gmp=3D/opt/local/ --with-mpfr=3D/opt/local/ --with-mpc=3D/opt/local/=