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

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

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

        .align 4
        .globl foo
        .type foo,@object
        .size foo,0 ; <-----
        .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
% cat bar.c
extern int foo[];

int main(int ac, char *av)
        return foo[1];
% pcc bar.c -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 made changes - 05/Jul/11 10:18 PM
Field Original Value New Value
Assignee Anders Magnusson [ ragge ]
Anders Magnusson made changes - 05/Jul/11 10:19 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]