Issue Details (XML | Word | Printable)

Key: PCC-2
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Mattias Pantzare
Votes: 0
Watchers: 1

If you were logged in you would be able to see more operations.

Pcc adds extra _ to symbol names

Created: 15/Nov/08 06:45 PM   Updated: 09/Feb/09 11:48 PM
Component/s: i386 target
Affects Version/s: None
Fix Version/s: None

Environment: Mac OS X i386

 Description  « Hide
Functions defined like this:

ssize_t write(int, const void *, size_t) __asm("_" "write" "$UNIX2003");

gets an extra _ in the symbol. It shoud link to _write$UNIX2003 but links to __write$UNIX2003

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Gregory McGarry added a comment - 08/Dec/08 08:53 AM
The problem is that renamed functions are being converted to an soname in pftn.c::411 and exname() is called on soname in trees:2151.

Either we could try to remove the leading underscore when it's first detected as a pragma_renamed at cgram.y::609, or mark the soname as having already been prefixed with the underscore.

This is a fatal problem on OS X 10.5. Nothing will compile against the standard headers.

Anders Magnusson added a comment - 11/Dec/08 04:13 PM
I think that the best way to solve this is to call exname() directly when soname is assigned, so that the
assigning routine can decide what to do. Needs a little bit thinking + hashing of the new name to avoid
excess use of memory though.

Anders Magnusson added a comment - 15/Dec/08 08:33 AM
Some more thinking tells that this might not be the best way to solve it; external names are
always assigned for all symbols, so it would create a bunch of unneccessary stuff in the name
hash table. Another way of doing it is to have a "do not exname()" flag on the symtab entry.

Gregory McGarry added a comment - 26/Jan/09 09:52 PM
I like the idea of add a flag to symtab. There is already a target-specific flag in the i386/powerpc targets (NOUNDERSCORE = SLOCAL1) to avoid prefixing pic labels. Making this an MI flag in the symtab sounds like a nice idea.

Anders Magnusson added a comment - 28/Jan/09 08:48 AM
There is yet another way to do it that might be even better: When soname is used (given to pass2), check if it is a null pointer.
If it is, call exname() to set it. Then a symbol rename function can assign soname directly and it will not be touched again.

Anders Magnusson added a comment - 08/Feb/09 05:03 PM
I've changed the syntax of soname now according to the last thought: if soname is set, use it, otherwise use exname() on sname.

Mattias Pantzare added a comment - 08/Feb/09 11:45 PM
The error is still there.

Anders Magnusson added a comment - 09/Feb/09 06:25 PM
Not when I try it. Example that exposes the bug please?

Gregory McGarry added a comment - 09/Feb/09 11:41 PM
Seems to be working okay for me. I haven't done extensive tests, but the following code does work:

int write(int, const void *, int) __asm("_" "write" "$UNIX2003");

char c;

read(0, &c, 1);
return write(1, &c, 1);

There's another bug, logged as PCC-30 which now comes into play though.