Symbol refptr refaddr unsigned 0x80483c8 4

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: strong symbols. Uninitialized global variables get weak symbols. For the example program in Figure 7.1, buf, bufp0, main, and swap are strong symbols; bufp1 is a weak symbol. Given this notion of strong and weak symbols, Unix linkers use the following rules for dealing with multiplydefined symbols: ¯ ¯ ¯ Rule 1: Multiple strong symbols are not allowed. Rule 2: Given a strong symbol and multiple weak symbols, choose the strong symbol. Rule 3: Given multiple weak symbols, choose any of the weak symbols. For example, suppose we attempt to compile and link the following two C modules: 1 2 3 4 5 /* foo1.c */ int main() { return 0; } 1 2 3 4 5 /* bar1.c */ int main() { return 0; } In this case the linker will generate an error message because the strong symbol main is defined multiple times (Rule 1): unix> gcc foo1.c bar1.c /tmp/cca015022.o: In function ‘main’: /tmp/cca015022.o(.text+0x0): multiple definition of ‘main’ /tmp/cca015021.o(.text+0x0): first defined here Similarly, the linker will generate an error message for the following modules because the strong symbol x is de...
View Full Document

Ask a homework question - tutors are online