DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 1 Week Ago
TCH TCH is offline
Shell Scout
 
Join Date: Mar 2017
Posts: 89
Default Shrink shared object

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?
Reply With Quote
Reply

Tags
linker, segment, shared object, shrink

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
/usr/pkg/lib/libsmbconf.so.0: Shared object "libldap.so.4" not found rdikarlus NetBSD Package System (pkgsrc) 2 31st August 2023 06:57 PM
Shared object libexecinfo.so.0 not found philo_neo71 NetBSD Installation and Upgrading 14 18th December 2014 12:05 AM
Is anyone doing Object Oriented Programming with Plain Ol' C? tetrodozombie Programming 4 19th December 2009 12:15 PM
Delphi or Object Pascal In OpenBSD? SunSpyda Programming 14 28th November 2009 11:21 AM
Shared object not found 'libwrap.so.4' magic FreeBSD General 3 22nd July 2009 09:36 PM


All times are GMT. The time now is 06:47 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick