[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/18963] New: Addition is not commutative
From: |
felix.von.s at posteo dot de |
Subject: |
[Bug ld/18963] New: Addition is not commutative |
Date: |
Tue, 15 Sep 2015 13:28:48 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=18963
Bug ID: 18963
Summary: Addition is not commutative
Product: binutils
Version: 2.25
URL: http://www.zytor.com/pub/git/dos/virtio9p.git/
Status: NEW
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: felix.von.s at posteo dot de
Target Milestone: ---
Created attachment 8610
--> https://sourceware.org/bugzilla/attachment.cgi?id=8610&action=edit
Failing linker script
I've recently stumbled upon <http://www.zytor.com/pub/git/dos/virtio9p.git/>
and decided to try it. I cloned the repository, ran "make", started the
executable in qemu, and it promptly crashed.
I looked into the map file and noticed that the entry point address in the
header is wrong. After about half an hour, I found a fix:
+++ dostsr.ld
- __init_lma = __dgroup_lma + __rbss_start - __init_vma;
+ __init_lma = __dgroup_lma - __init_vma + __rbss_start;
[...]
- _exe_start = _start + __rbss_start - __init_vma;
+ _exe_start = _start - __init_vma + __rbss_start;
[...]
- _edata_premove = _edata + __rbss_start - __init_vma;
+ _edata_premove = _edata - __init_vma + __rbss_start;
For some reason, wherever the linker script contained definition of the form A
= B + C - D, ld silently took it to mean A = B + C + D. Changing the order of
summation fixed the problem.
It doesn't always happen, though: when I tried to create a minimal test case,
sometimes the link succeeded, sometimes it didn't. The result seems to depend
on whether there is overflow in the computation. The attached script fails to
link; however, if I instead set D = A - B + C and E = A + C - B, it links
successfully.
gold refused to link the original executable altogether, since it has
overlapping sections (for good reasons, though). The attached script is linked
without surprises.
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/18963] New: Addition is not commutative,
felix.von.s at posteo dot de <=
- [Bug ld/18963] Addition is not commutative, nickc at redhat dot com, 2015/09/16
- [Bug ld/18963] Addition is not commutative, nickc at redhat dot com, 2015/09/16
- [Bug ld/18963] Addition is not commutative, felix.von.s at posteo dot de, 2015/09/16
- [Bug ld/18963] Addition is not commutative, amodra at gmail dot com, 2015/09/16
- [Bug ld/18963] Addition is not commutative, cvs-commit at gcc dot gnu.org, 2015/09/17
- [Bug ld/18963] Addition is not commutative, amodra at gmail dot com, 2015/09/18