bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/18452] New: ld allows overlapping sections


From: kalmquist1 at hotmail dot com
Subject: [Bug ld/18452] New: ld allows overlapping sections
Date: Sun, 24 May 2015 22:41:44 +0000

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

            Bug ID: 18452
           Summary: ld allows overlapping sections
           Product: binutils
           Version: 2.24
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: kalmquist1 at hotmail dot com
  Target Milestone: ---

Created attachment 8331
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8331&action=edit
test data

According to section 3.10.5 (title "The Location Counter"):

    The location counter may not be moved backwards inside an output
    section, and may not be moved backwards outside of an output
    section if so doing creates areas with overlapping LMAs.

Contrary to the documentation, LD actually allows creating overlapping
sections, at least if one of the overlapping sections is the ".bss"
section.

The reason that this has the potential to be a serious problem is that
if a linker script uses fixed addresses for output sections, there
is a chance that changes to the program being linked will cause one
of the output sections to increase in size so that it overlaps the
section that follows it.  If LD doesn't treat this condition as an
error, the result is likely to be malfunctions which are difficult to
debug.  For example, if the .bss section overlaps the .text section,
then the calling one function could overwrite a portion of the code
of a completely unrelated function, and no problem would be evident
until the latter function was called.


To reproduce the problem, unpack the attached tar file into an empty
directory and run the command "sh mk".  That will assemble and link
an object file named "lib.out", and run objdump and nm on it.  The
expected behavior (if the bug has not been fixed) is that
1)  The ld command will not produce any messages.
2)  The objdump command will show that the .text and .bss segments
    overlap.
3)  The nm command will show that the linker has assigned the same
    address to both main (a function) and var2 (a variable).


The following command output describes the system I am using:
$ /usr/bin/ld -version
GNU ld (GNU Binutils for Ubuntu) 2.24
Copyright 2013 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
$ ldd /usr/bin/ld
        linux-vdso.so.1 =>  (0x00007fff21b1e000)
        libbfd-2.24-system.so => /usr/lib/libbfd-2.24-system.so
(0x00007fdf47641000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fdf4743d000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdf47077000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fdf46e5e000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fdf47985000)
$ ls -l /lib/x86_64-linux-gnu/libdl.so.2
lrwxrwxrwx 1 root root 13 Feb 25 11:56 /lib/x86_64-linux-gnu/libdl.so.2 ->
libdl-2.19.so
$ ls -l /lib/x86_64-linux-gnu/libc.so.6
lrwxrwxrwx 1 root root 12 Feb 25 11:56 /lib/x86_64-linux-gnu/libc.so.6 ->
libc-2.19.so
$ ls -l /lib/x86_64-linux-gnu/libz.so.1
lrwxrwxrwx 1 root root 13 Aug 14  2014 /lib/x86_64-linux-gnu/libz.so.1 ->
libz.so.1.2.8
$ uname --kernel-name
Linux
$ uname --kernel-release
3.13.0-36-generic
$ uname --kernel-version
#63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014
$ uname --machine
x86_64
$ lsb_release -d
Description:    Ubuntu 14.04.2 LTS
$ # CPU is Intel i5-4690K (Haswell)

-- 
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]