Issue Details (XML | Word | Printable)

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

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

pre-initialized shared objects have no size

Created: 28/Feb/11 11:01 PM   Updated: 01/Mar/11 09:23 AM
Component/s: i386 target
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386

 Description  « Hide
The following two source files

int bar = 4;

extern int bar;

int main(int ac, char *av)
    bar = 0;

when compiled with

pcc -c bar.c
pcc -shared bar.o -o
pcc -c foo.c
pcc foo.o

results in

ld: dynamic variable `bar' is zero size
ld: foo.o(.text+0x5): unresolvable R_386_32 relocation against symbol `bar'
ld: final link failed: Nonrepresentable section on output

this is because bar has no size.. inserting a size statement to bar.s as per

--- bar.s.orig 2011-02-28 21:49:38.000000000 +0000
+++ bar.s 2011-02-28 21:49:44.000000000 +0000
@@ -1,8 +1,9 @@
        .align 4
        .globl bar
        .type bar,@object
        .long 4
+ .size bar,4
        .comm baz,04,4
        .ident "PCC: pcc 1.1.0.DEVEL [20110221] (netbsd)"

allows it to link properly..

I looked in the source and find that eoftn() emits a size statement for functions and defzero() for empty variables, but I don't really see where it should happen for initialized objects..

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 01/Mar/11 09:23 AM
I've added size to i386 now. Can you please check that it works and don't give any side effects? Then I'll pull it up to 1.0.