Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Oct 2001 08:30:37 -0700
From:      Mark Peek <mark@whistle.com>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   Change to ldscript.i386
Message-ID:  <p05101000b7e77470ca47@[207.76.207.129]>

next in thread | raw e-mail | index | archive | help
I made a change to page align the data segment on the powerpc port and I
noticed something strange with the i386 alignment. The data section appears
to be wasting space by aligning to the same address (offset) in the next
page rather than to the next page boundary. Below is the patch and a
before/after objdump of the kernel headers. The difference isn't that big
(no more than 4K) but my patch seems more correct.

Am I missing any reason why it was done this way? If not, I'll apply the
patch to -current.

Thanks,
Mark

-------------

Index: ldscript.i386
===================================================================
RCS file: /cvs/freebsd/src/sys/conf/ldscript.i386,v
retrieving revision 1.5
diff -u -u -r1.5 ldscript.i386
--- ldscript.i386	2001/09/18 01:12:43	1.5
+++ ldscript.i386	2001/09/24 22:34:02
@@ -55,9 +55,8 @@
   .fini      : { *(.fini)    } =0x9090
   .rodata    : { *(.rodata) *(.gnu.linkonce.r*) }
   .rodata1   : { *(.rodata1) }
-  /* Adjust the address for the data segment.  We want to adjust up to
-     the same address within the page on the next page up.  */
-  . = ALIGN(0x1000) + (. & (0x1000 - 1)) ; 
+  /* Adjust the address for the data segment to the next page up. */
+  . = ((. + 0x1000) & ~(0x1000 - 1));
   .data    :
   {
     *(.data)

Before patch:

kernel:     file format elf32-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .interp       0000000d  c01000d4  c01000d4  000000d4  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .hash         000095f0  c01000e4  c01000e4  000000e4  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .dynsym       00015770  c01096d4  c01096d4  000096d4  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .dynstr       00014352  c011ee44  c011ee44  0001ee44  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .text         00207448  c01331a0  c01331a0  000331a0  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  5 .rodata       0005bfa0  c033a600  c033a600  0023a600  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 set_modmetadata_set 0000050c  c03965a0  c03965a0  002965a0  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 set_sysinit_set 00000894  c0396aac  c0396aac  00296aac  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  8 set_sysctl_set 00000b44  c0397340  c0397340  00297340  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 set_db_cmd_set 00000004  c0397e84  c0397e84  00297e84  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 10 set_db_show_cmd_set 00000044  c0397e88  c0397e88  00297e88  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 11 set_sysuninit_set 00000338  c0397ecc  c0397ecc  00297ecc  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 12 set_kbddriver_set 00000008  c0398204  c0398204  00298204  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 13 set_cons_set  0000000c  c039820c  c039820c  0029820c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 14 set_videodriver_set 00000010  c0398218  c0398218  00298218  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 15 set_scterm_set 00000004  c0398228  c0398228  00298228  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 16 set_scrndr_set 0000001c  c039822c  c039822c  0029822c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 17 set_vga_set   0000001c  c0398248  c0398248  00298248  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 18 .data         00049d20  c0399280  c0399280  00298280  2**5
                  CONTENTS, ALLOC, LOAD, DATA
 19 .got          0000000c  c03e2fa0  c03e2fa0  002e1fa0  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 20 .dynamic      00000040  c03e2fac  c03e2fac  002e1fac  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 21 .bss          00035534  c03e3000  c03e3000  002e2000  2**5
                  ALLOC
 22 .comment      00008caf  00000000  00000000  002e2000  2**0
                  CONTENTS, READONLY
 23 .note         00003688  00000000  00000000  002eacaf  2**0
                  CONTENTS, READONLY



After patch:

kernel:     file format elf32-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .interp       0000000d  c01000d4  c01000d4  000000d4  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .hash         000095f0  c01000e4  c01000e4  000000e4  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .dynsym       00015770  c01096d4  c01096d4  000096d4  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .dynstr       00014352  c011ee44  c011ee44  0001ee44  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .text         00207448  c01331a0  c01331a0  000331a0  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  5 .rodata       0005bfa0  c033a600  c033a600  0023a600  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 set_modmetadata_set 0000050c  c03965a0  c03965a0  002965a0  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 set_sysinit_set 00000894  c0396aac  c0396aac  00296aac  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  8 set_sysctl_set 00000b44  c0397340  c0397340  00297340  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 set_db_cmd_set 00000004  c0397e84  c0397e84  00297e84  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 10 set_db_show_cmd_set 00000044  c0397e88  c0397e88  00297e88  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 11 set_sysuninit_set 00000338  c0397ecc  c0397ecc  00297ecc  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 12 set_kbddriver_set 00000008  c0398204  c0398204  00298204  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 13 set_cons_set  0000000c  c039820c  c039820c  0029820c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 14 set_videodriver_set 00000010  c0398218  c0398218  00298218  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 15 set_scterm_set 00000004  c0398228  c0398228  00298228  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 16 set_scrndr_set 0000001c  c039822c  c039822c  0029822c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 17 set_vga_set   0000001c  c0398248  c0398248  00298248  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 18 .data         00049d20  c0399000  c0399000  00299000  2**5
                  CONTENTS, ALLOC, LOAD, DATA
 19 .got          0000000c  c03e2d20  c03e2d20  002e2d20  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 20 .dynamic      00000040  c03e2d2c  c03e2d2c  002e2d2c  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 21 .bss          00035534  c03e2d80  c03e2d80  002e2d80  2**5
                  ALLOC
 22 .comment      00008caf  00000000  00000000  002e2d80  2**0
                  CONTENTS, READONLY
 23 .note         00003688  00000000  00000000  002eba2f  2**0
                  CONTENTS, READONLY

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p05101000b7e77470ca47>