I have a small lib:
Code:
#include <stdio.h>
void hello()
{
printf("Hello World!\n");
}
And a symbol export map:
Code:
{
global:
hello;
local:
*;
};
I build the shared object with these commands:
Code:
cc -O2 -c -fPIC hello.c -o hello.o
ld -o libhello.so -shared --version-script=hello.map --strip-all -soname=libhello.so hello.o
Now i have a library, which is ~13kB. The IDA disassembler shows only 170 bytes of code and data in all of the segments in the SO, but the segments are still 4kB big. Is this because they are not sized by bytes, but 4kB pages? Can the page size be changed?
I tried to search for it, but i found nothing about how these shared objects are actually built up and what can be omitted from those parts, only tutorials about how to compile and link them.
Also, it seems, that the library's dependencies' names are also exported. If i do
Code:
objdump -T libhello.so
i get
Code:
0000000000000000 D *UND* 0000000000000000 puts
0000000000001020 g DF .text 000000000000000c hello
(
nm and
readelf reports the same symbols.) And i can reach
puts(), via the library, if i put
Code:
extern int puts(const char *s);
into the included header. But that is not intended, i only would like to make
hello() available via the lib. Must those dependency symbol names be exported?