Project

General

Profile

Bug #3453

GNU comdat redirection does exactly the wrong thing

Added by Rich Lowe almost 8 years ago. Updated almost 8 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
tools - gate/build tools
Start date:
2013-01-09
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

In gnu_comdat_sym we attempt to determine whether a section name is that of a GNU comdat section, which are named '<sectionname>.<signaturesymbolname>'.

We do this by iterating all sections looking for a section which is not ourselves, which matches our name up to its own length, and is followed, in our name, by a '.'.

Unfortunately, what we do is this:

        ssize = strlen(isp->is_name);
        if ((strncmp(isp->is_name, gisp->is_name, ssize) != 0) &&
            (gisp->is_name[ssize] == '.'))
            return ((char *)&gisp->is_name[ssize]);

Notice how in the above, what we are actually doing is making sure that the name is not a prefix of our own, but would in our own be followed by a '.'

This actually works surprisingly often, but only because '.data' and '.text' are the same length. When it fails, the results are catastraphic (but sometimes work anyway, because of the wonder of ELF)

#1

Updated by Rich Lowe almost 8 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 40 to 100

Resolved in 84f7afe

Also available in: Atom PDF