Issue Details (XML | Word | Printable)

Key: PCC-369
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0
Operations

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

size of array is output as zero

Created: 05/Jul/11 12:01 PM   Updated: 05/Jul/11 10:19 PM
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386


 Description  « Hide
defined array objects are output as size zero, causing errors when linking
from another module, eg

int foo[] = { 1, 2, 3 };

when compiled with pcc -S produces code

        .data
        .align 4
        .globl foo
        .type foo,@object
        .size foo,0 ; <-----
foo:
        .long 1
        .long 2
        .long 3
        .ident "PCC: pcc 1.1.0.DEVEL 20110701 for netbsd-i386"

this is not a problem in itself, but when this is built as a shared object and
linked from an external program, ld fails, eg

% cat foo.c
int foo[] = { 1, 2, 3 };
% pcc -shared foo.c -o foo.so
% cat bar.c
extern int foo[];

int main(int ac, char *av)
{
        return foo[1];
}
% pcc bar.c foo.so -o bar
ld: dynamic variable `foo' is zero size
ld: /tmp/ctm.16459c(.text+0x7): unresolvable R_386_32 relocation against symbol `foo'
ld: final link failed: Nonrepresentable section on output


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 05/Jul/11 10:19 PM
Fixed by reorder calculation of array size and printing out the symbol names.