[Bug ld/24144] New: Gnu ld for PDP-11 is creating corrupt output. NULL inserted in data section.

2019-01-27 Thread mattislind at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24144

Bug ID: 24144
   Summary: Gnu ld for PDP-11 is creating corrupt output. NULL
inserted in data section.
   Product: binutils
   Version: 2.31
Status: UNCONFIRMED
  Severity: critical
  Priority: P2
 Component: ld
  Assignee: unassigned at sourceware dot org
  Reporter: mattislind at gmail dot com
  Target Milestone: ---

When linking PDP-11 a.out files the linker seemingly random replaces bytes in
the data section with NULL bytes.

I am having trouble with a very small program in C that is compiled and linked
with PDP-11 GCC. The version is gcc version 9.0.0 20181209 (experimental)
(GCC). The host system is MACOS 10.8.5

GNU LD is version 2.31

The code is located here: https://github.com/MattisLind/pdp11-plot

make -f Makefile.pdp11

The problem is in the main.o file and the resulting testplot.o 

If I do a 
pdp11-aout-objdump  -s main.o > main.objdump

and check the objdump I find the sequence 29 41 7d 29 2b 5c 29 14 40 at
location 23e

023e 2a521f29 417d292b 5c291440 21752621

If I do the same command on testplot.o

pdp11-aout-objdump  -s testplot.o > testplot.objdump

Now at location b20 I get this 

0b20 2a521f29 417d292b 5c001440 21752621

29 has became 00!

I simply cannot understand what is going wrong that could cause it to seemingly
random replace things with 00


Linking command:

testplot.o: crt0.o main.o bresenham.o pdp-xy11.o printf.o divmulmod.o xorhi3.o
ashlhi3.o 
@pdp11-aout-ld   -T linker-script   -nostartfiles  -nodefaultlibs 
-nostdlib  $^  -o $@

linker-script:

localhost:pdp11-plot mattislind$ cat linker-script 
OUTPUT_FORMAT("a.out-pdp11")
phys = 0200;
SECTIONS
{
  .text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(0100);
  }
  .data : AT(phys + (data - code))
  {
data = .;
*(.data)
. = ALIGN(0100);
  }
  .bss : AT(phys + (bss - code))
  {
bss = .;
*(.bss)
. = ALIGN(0100);
  }
  end = .;

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/24144] Gnu ld for PDP-11 is creating corrupt output. NULL inserted in data section.

2019-01-31 Thread mattislind at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24144

--- Comment #1 from Mattis Lind  ---
This problem can be worked around as it seems by using different alignment in
the linker script. 

This linker-script make ld work fine:

OUTPUT_FORMAT("a.out-pdp11")
phys = 0200;
SECTIONS
{
  .text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(2);
  }
  .data : AT(phys + (data - code))
  {
data = .;
*(.data)
. = ALIGN(2);
  }
  .bss : AT(phys + (bss - code))
  {
bss = .;
*(.bss)
. = ALIGN(2);
  }
  end = .;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/24144] Gnu ld for PDP-11 is creating corrupt output. NULL inserted in data section.

2019-02-22 Thread mattislind at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24144

--- Comment #5 from Mattis Lind  ---
Thank you Paul for adding your files!

Just a comment on the alignment.

It might very well be that an alignment of two puts the nulls somewhere outside
the data section. Hover I added a separate make target just to compare the data
sections of the ten different targets my Makefile produced. The size of the
data section varied quite substantially between the different targets. From 904
bytes to 9852 bytes. Not one single case out of the twelve targets had faulty
data sections. I.e. the data section was identical after linking.

Now this is not a proof for alignment of two is working or that alignment has
something to do with the problem. But it might give an idea.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils