Bug 12066 - cannot move location counter backwards (from 00000000000067e0 to 0000000000000000)
Summary: cannot move location counter backwards (from 00000000000067e0 to 000000000000...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-27 13:55 UTC by Marcin Juszkiewicz
Modified: 2011-05-13 21:47 UTC (History)
2 users (show)

See Also:
Host: x86_64-linux-gnu
Target: i586-linux-gnu
Build:
Last reconfirmed: 2010-09-29 12:08:39


Attachments
Coreboot object which fail to link + linker scripts (204.95 KB, application/x-bzip)
2010-09-29 11:44 UTC, Marcin Juszkiewicz
Details
Seabios object which fail to link + linker script (178.60 KB, application/x-bzip)
2010-09-29 11:46 UTC, Marcin Juszkiewicz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcin Juszkiewicz 2010-09-27 13:55:15 UTC
Today I tried to compile coreboot and seabios for one of my boards. It failed under Ubuntu so I tried Debian chroot.

It compiled fine under Debian so I tried to find out where is a problem. Matthias Klose pointed me at binutils and it was proper hint.

Current (2.20.51.20100925-1) version in Debian/experimental had same problem as Ubuntu one (2.20.51.20100908-0ubuntu2). So I fetched few 
versions from snapshot.debian.org and started testing.

Last good version was 2.20.51.20100527-1 - both project compiled without problems.

coreboot (svn://coreboot.org/coreboot/trunk@5858) failure:

gcc -m32 -Wa,--divide -fno-stack-protector -Wl,--build-id=none -nostdlib -nostartfiles -static -o build/coreboot_ram -Lbuild -T 
src/arch/i386/coreboot_ram.ld build/coreboot_ram.o
src/arch/i386/coreboot_ram.ld:143 cannot move location counter backwards (from 0000000000118000 to 0000000000004000)
collect2: ld returned 1 exit status
make: *** [build/coreboot_ram] Error 1

seabios (94dc9c49c283cd576c25692d17567035557a2505 revision) failure:

  Linking out/rom16.o
ld -T out/romlayout16.lds out/code16.o -o out/rom16.o
out/romlayout16.lds:429 cannot move location counter backwards (from 00000000000067e0 to 0000000000000000)
make: *** [out/rom16.o] Error 1
Comment 1 Marcin Juszkiewicz 2010-09-29 10:17:10 UTC
Bisected binutils git tree (git://repo.or.cz/binutils.git) and this commit broke 
it:

commit 557189b0dd1f3dec6b00b91b9b0c5459ece72a52
Author: Alan Modra <amodra@bigpond.net.au>
Date:   Thu Aug 19 05:51:47 2010 +0000

    binutils/
        * NEWS: Mention change in linker script expression evaluation.
    ld/
        * ld.texinfo (Expression Section): Detail expression evaluation.
        (Builtin Functions <ADDR>): Correct.
        (Builtin Functions <LOADADDR>): Don't mention LOADADDR normally
        the same as ADDR.
        (Builtin Functions <SEGMENT_START>): Typo fix.
        * ldexp.c (new_number): New function.
        (make_abs, exp_get_abs_int): Cope with NULL expld.result.section.
        (fold_unary <'~', '!', '-'>): Don't make_abs.
        (fold_binary): Simplify result section logic.  Return NULL section
        for logical ops.
        (fold_binary <SEGMENT_START>): Use new_rel_from_abs to set value to
        a consistent result.
        (fold_name <SIZEOF_HEADERS>): Return new_number, not new_abs.
        (fold_name <DEFINED, SIZEOF, ALIGNOF, LENGTH, CONSTANT>): Likewise.
        (fold_name <NAME>): No need to handle absolute symbols differently
        from relative ones.
        (fold_name <ORIGIN>): Don't return valid result when
        lang_first_phase_enum.  Return new_rel_from_abs, not new_abs.
        (exp_fold_tree_1 <etree_value>): Return new_number, not new_rel.
        (exp_fold_tree_1): Ajust for NULL expld.result.section.  When assigning
        a plain number to dot, assume the value is relative to expld.section.
        Make terms not in an output section, absolute.
        * ldlang.c (print_assignment): Fix style nit.
        (lang_size_sections_1): Cope with NULL expld.result.section.
        (lang_do_assignments_1): Likewise.
    ld/testsuite/
        * ld-scripts/memory.t: Remove ORIGIN fudge.
Comment 2 Marcin Juszkiewicz 2010-09-29 10:24:15 UTC
How to reproduce:

$ git clone git://git.linuxtogo.org/home/kevin/seabios.git
$ git checkout 94dc9c49c283cd576c25692d17567035557a2505
$ cd seabios
$ make V=1
Comment 3 Marcin Juszkiewicz 2010-09-29 11:44:30 UTC
Created attachment 5020 [details]
Coreboot object which fail to link + linker scripts

Minimal set of files from coreboot to get link error reproduced. Extract and
run "test.sh" script.
Comment 4 Marcin Juszkiewicz 2010-09-29 11:46:03 UTC
Created attachment 5021 [details]
Seabios object which fail to link + linker script

Minimal set of files from seabios to get link error reproduced. Extract and run
"test.sh" script.
Comment 5 Marcin Juszkiewicz 2010-10-15 15:51:51 UTC
17:49 hrw@home:coreboot-trunk$ ld --version
GNU ld (GNU Binutils for Ubuntu) 2.20.51-system.20101014

This snapshot version allows me to link both coreboot and seabios.
Comment 6 Alexey Zaytsev 2011-05-13 21:30:54 UTC
Hey, was it actually FIXED? I'm getting an error with the current Debian testing binutils, and it looks very similar.

GNU ld (GNU Binutils for Debian) 2.21.0.20110327


$ make
  Build Kconfig config file
  Compiling whole program out/ccode.16.s
  Compiling to assembler out/asm-offsets.s
  Generating offset file out/asm-offsets.h
  Compiling (16bit) out/code16.o
  Compiling whole program out/ccode32flat.o
  Compiling whole program out/code32seg.o
  Building ld scripts (version "pre-0.6.3-20110514_013119-zaytsev")
Fixed space: 0xe05b-0x10000  total: 8101  slack: 2  Percent slack: 0.0%
16bit size:           39520
32bit segmented size: 1636
32bit flat size:      12380
32bit flat init size: 56992
  Linking out/rom16.o
out/romlayout16.lds:691 cannot move location counter backwards (from 000000000000ca25 to 000000000000ca0c)
make: *** [out/rom16.o] Error 1
Comment 7 Alexey Zaytsev 2011-05-13 21:47:39 UTC
Just checked with the latest 2.21 snapshot, works fine, sorry for the noise.