bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/18963] Addition is not commutative


From: casner at acm dot org
Subject: [Bug ld/18963] Addition is not commutative
Date: Thu, 09 Apr 2020 20:42:57 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=18963

Stephen Casner <casner at acm dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |casner at acm dot org

--- Comment #6 from Stephen Casner <casner at acm dot org> ---
The test pr18963.t introduced with this update fails for the
pdp11-aout target because the source file is empty and the output file
is built entirely in the linker script.  That means the file size does
not match the sizes in the a.out header, so nm cannot open the file.

I am trying a replacement test that allocates text, data and bss space
in a pr18963.s file instead, and then makes similar symbol assignments
after those sections in the linker script.

A second problem is that the output size from the existing linker
script is larger than the 16-bit address space of the pdp11, but I
believe that scaling down the sizes by a factor of 0x100 imposes no
loss of generality.

To validate my modified test script I have backed up to commit
a8aa551e5abde13e063beb32ec0366bdc6008d71 before this update and then I
built for target i386-elf32 which looks that the target in use for the
initial bug report.

I then copied pr18963.d and pr18963.t into this tree and edited
pr18963.t to remove the ASSERT so I could examine the result from nm
(in alphabetical sort):

00080000 T A
00090000 T B
000a0000 D C
00070000 T D
00090000 D E
00080000 T _start

Since D!=E this verifies a replication of the bug conditions.

Then I put in place my proposed new test consisting of source file
pr18963.s:

        .globl  _start
        .text
_start:
        .=.+0x800
        .globl  _data
        .data
_data:
        .=.+0x100
        .globl  _bss
        .bss
_bss:
        .=.+0x100
        .end

Modified linker script pr18963.t using the sections from the input but
still defining the symbols outside of the sections:

SECTIONS
{
  .text :
  {
    *(.text)
  }
  A = .;
  .data :
  {
    *(.data)
  }
  B = .;
  .bss :
  {
    *(.bss)
  }
  C = .;
  D = A - C + B;
  E = A + B - C;
  /DISCARD/ : {*(*)}
}

And test script pr18963.d modified just by changing the source file
and scaling down by 0x100:

# source: pr18963.s
# ld: -T pr18963.t
# nm: -B -n

#...
0+700 A D
#...
0+700 A E
#...
0+800 T A
#...
0+900 D B
#...
0+a00 B C
#pass

The result result from nm (again in alphabetical sort) is:

00000800 T A
00000900 D B
00000a00 B C
00000700 D D
00001900 B E
00000900 B _bss
00000800 D _data
00000000 T _start

I see that D = 0x700 (as expected by scaling the 0x70000 result from
the original linker script by 0x100) but E = 0x1900 rather than 0x900
(the original linker script result was 0x90000).  I don't have an
explanation for that difference, but I do see that E is relocated to
bss rather than to data as in the result from the original linker
script.

My revised test passes for both i386-elf32 and pdp11-aout with the
current source tree.  Would you accept it as a replacement (with the
ASSERT put back in)?  If so, I will prepare a patch.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]