2009-06-16 10:47:49     VZS in FDPIC mode

Document created by Aaronwu Employee on Aug 15, 2013
Version 1Show Document
  • View in full screen mode

2009-06-16 10:47:49     VZS in FDPIC mode

victor nikonov (BELARUS)

Message: 75825   

 

Hi

I've run a small program in two variants(FDPIC & Shared-FLAT) and have got very large VSZ in FDPIC format(492kb) against Shared-FLAT(12k).

How cat I decrise VSZ for FDPIC variant if it's possible? When I use Shared-FLAT - I've save ~2MB as I see from "cat /proc/meminfo", but I

have to use FDPIC because in other programs I use FDPIC libs(witout sources).

 

Best Regards

Victor Nikonov

 

FOR FDPIC

# ps

  PID Uid VSZ Stat Command

  1 root 588 S /init

  ...

  155 root 856 R -/bin/sh

  162 root 492 S Hello1

  163 root 492 S Hello2

  164 root 760 R ps

 

FOR SHARED_FLAT

# ps

  PID Uid VSZ Stat Command

  1 root 328 S /init

  ...

  155 root 580 R -/bin/sh

  163 root 12 S Hello1

  167 root 12 S Hello2

  168 root 484 R ps

 

 

 

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <sys/wait.h>

#include <sys/stat.h>

 

int main(int argc, char **argv)

  printf("Hello1..\n");

  while (1)

  {

sleep(80);

  }

  return 0; 

}

 

 

BNAME_HELLO1 := Hello1

SRC_HELLO1 := Hello1.c

OBJ_HELLO1 := Hello1.o

 

CFLAGS=-Wall -g -O0

 

all: $(BNAME_HELLO1)

 

$(BNAME_HELLO1): $(OBJ_HELLO1)

$(CC) $^ $(LDFLAGS) -o $@

 

$(OBJ_HELLO1): $(SRC_HELLO1)

$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@

 

clean:

rm -f $(OBJ_HELLO1)

rm -f $(BNAME_HELLO1)

romfs:

$(ROMFSINST) -d -e CONFIG_FMT_USE_FDPIC_ELF /bin/$(BNAME_HELLO1)

# $(ROMFSINST) -d -e CONFIG_FMT_USE_SHARED_FLAT /bin/$(BNAME_HELLO1)

QuoteReplyEditDelete

 

 

2009-06-16 10:54:17     Re: VZS in FDPIC mode

Mike Frysinger (UNITED STATES)

Message: 75827   

 

the 492 is not dedicated solely to your application.  also included in that summary are all of the FDPIC libraries which all applications need to use.

 

you have to look in /proc/<pid>/maps to see the memory that is actually specific to each application.

 

also, the default stack for FDPIC applications is 128k vs 4k for FLAT.  read the documentation for more information there:

https://docs.blackfin.uclinux.org/doku.php?id=uclinux-dist:debugging_applications

QuoteReplyEditDelete

 

 

2009-06-18 06:21:51     Re: VZS in FDPIC mode

victor nikonov (BELARUS)

Message: 75958   

 

I've run 2 variats of program:

 

[]$ bfin-linux-uclibc-readelf -l Hello1

  GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x01000 RWE 0x8

 

[]$ bfin-linux-uclibc-readelf -l Hello2

  GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8

 

"/proc/pid/maps" are the same for both:

 

# cat /proc/204/maps

00200000-0023d000 r-xs 00000000 00:01 125 /lib/libuClibc-0.9.29.so

002d1000-002d2000 r-xs 00000000 00:01 99 /bin/Hello2

002d8000-002dd000 rw-p 00000000 00:00 0

01960000-0196b000 r-xs 00000000 00:01 126 /lib/libgcc_s.so.1

01978000-01980000 r-xs 00000000 00:01 156 /lib/ld-uClibc-0.9.29.so

01a00000-01a20000 rwxp 00000000 00:00 0

01a80000-01a82000 rw-p 00000000 00:00 0

01ac2000-01ac3000 rw-p 00000000 00:00 0

01d9e000-01d9f000 rw-p 00007000 00:01 156 /lib/ld-uClibc-0.9.29.so

01dab000-01dac000 rw-p 00000000 00:01 99 /bin/Hello2

# cat /proc/206/maps

00200000-0023d000 r-xs 00000000 00:01 125 /lib/libuClibc-0.9.29.so

002d6000-002d8000 rw-p 00000000 00:00 0

002e0000-00300000 rwxp 00000000 00:00 0

00356000-00357000 rw-p 00000000 00:00 0

00367000-00368000 rw-p 00007000 00:01 156 /lib/ld-uClibc-0.9.29.so

00373000-00374000 rw-p 00000000 00:01 34 /bin/Hello1

0190d000-0190e000 r-xs 00000000 00:01 34 /bin/Hello1

01960000-0196b000 r-xs 00000000 00:01 126 /lib/libgcc_s.so.1

01978000-01980000 r-xs 00000000 00:01 156 /lib/ld-uClibc-0.9.29.so

01a90000-01a95000 rw-p 00000000 00:00 0

 

 

"/proc/pid/status" show in line "Mem" 192032 bytes for both.

 

In Shared-FLAT "Mem" is 19136.

 

Could you give me some more advice, to save memory? 

 

 

Best Regards

Victor Nikonov

QuoteReplyEditDelete

 

 

2009-06-18 10:17:31     Re: VZS in FDPIC mode

Mike Frysinger (UNITED STATES)

Message: 75974   

 

looks like there's a bug in the stack handling in the kernel.  the PHDRs of the ldso override the PHDRs of the ELF.  i'll file a bug about it.

QuoteReplyEditDelete

Attachments

    Outcomes