public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/94134] New: pdp11-aout puts initial variable into .text section rather than .data
@ 2020-03-11  6:52 casner at acm dot org
  2020-03-11  7:05 ` [Bug target/94134] " casner at acm dot org
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: casner at acm dot org @ 2020-03-11  6:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94134

            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 begins
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 section
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 = 0;
static int one = 1;
int main() {}

        .text
        .even

_zero:  .=.+ 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 correct:

Command: pdp11-aout-gcc -ffreestanding -nostdlib -S -o one.s one.c

static int one = 1;
static int zero = 0;
int main() {}

        .text
        .data
        .even
_one:
        .word   01
        .even

_zero:  .=.+ 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=pdp11-aout --prefix=/usr/local
--disable-libstdc++-v3 --disable-libssp --disable-libgfortran --disable-libobjc
--disable-libbacktrace --with-gmp=/opt/local/ --with-mpfr=/opt/local/
--with-mpc=/opt/local/

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2020-09-18  5:27 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11  6:52 [Bug target/94134] New: pdp11-aout puts initial variable into .text section rather than .data casner at acm dot org
2020-03-11  7:05 ` [Bug target/94134] " casner at acm dot org
2020-03-11  7:32 ` pinskia at gcc dot gnu.org
2020-03-11  7:34 ` pinskia at gcc dot gnu.org
2020-03-11  8:26 ` jakub at gcc dot gnu.org
2020-03-11 14:48 ` jakub at gcc dot gnu.org
2020-03-11 14:52 ` jakub at gcc dot gnu.org
2020-03-11 16:57 ` pkoning at gcc dot gnu.org
2020-03-11 17:37 ` jakub at gcc dot gnu.org
2020-03-11 20:14 ` casner at acm dot org
2020-03-11 20:19 ` casner at acm dot org
2020-03-11 21:10 ` pkoning at gcc dot gnu.org
2020-03-11 23:18 ` casner at acm dot org
2020-03-11 23:43 ` casner at acm dot org
2020-03-17 18:57 ` cvs-commit at gcc dot gnu.org
2020-09-17 14:24 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:18 ` jakub at gcc dot gnu.org
2020-09-18  5:27 ` casner at acm dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).