bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/13468] New: ld -z text: assertion in 2.22 and 2.22 when used wit


From: bernhard.kaindl at thalesgroup dot com
Subject: [Bug ld/13468] New: ld -z text: assertion in 2.22 and 2.22 when used without -shared
Date: Fri, 02 Dec 2011 17:38:54 +0000

http://sourceware.org/bugzilla/show_bug.cgi?id=13468

             Bug #: 13468
           Summary: ld -z text: assertion in 2.22 and 2.22 when used
                    without -shared
           Product: binutils
           Version: 2.22
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: address@hidden
        ReportedBy: address@hidden
    Classification: Unclassified
              Host: all
            Target: all
             Build: all


Hi Alan,

in the commit titled "PR ld/13254", you implemented ld -z text, but when used
without -shared, it leads to an assertion:

$ echo 'foo(){};_start(){foo();}' >foo.c
$ gcc -m32 -c foo.c
$ ./ld/ld-new foo.o -z text -m elf_i386
./ld/ld-new: BFD (GNU Binutils) 2.22 assertion fail ../../bfd/elflink.c:11198
Segmentation fault

This is because of the conditions you use to enable the checking in elflink.c:

 11190        /* Check for DT_TEXTREL (late, in case the backend removes it).
*/
 11191        if ((info->warn_shared_textrel && info->shared)
 11192            || info->error_textrel) <- This is the added condition
 11193          {
 11194            bfd_byte *dyncon, *dynconend;
 11195
 11196            /* Fix up .dynamic entries.  */
 11197            o = bfd_get_section_by_name (dynobj, ".dynamic");
 11198            BFD_ASSERT (o != NULL);

You can find the change you made at this place the second hunk of this diff:

http://sourceware.org/bugzilla/attachment.cgi?id=5966&action=diff

The thing is that line 11197 is only guaranteed to set o to a non-NULL-val when
info->shared is != 0, but you bypass this check with "|| info->error_textrel)".

info->error_textrel can only be active when info->shared is != 0.

I propose you change these lines as follows:

 11191        if (info->shared &&
 11192            (info->warn_shared_textrel ||
 11192             info->error_textrel))

Also, this makes is immediately clear to every reader that the textrel check
below is only entered when info->shared is set and (in addition) either
warn_shared_textrel or error_textrel are set.

I've cross-built a complete minimal system for powerpc and x86 with this fix
and
info->error_textrel set to true in the used cross ld by default.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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]