This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Reduce size of SymbianOS DLLs


The linker believed that SymbianOS BPABI DLLs were demand-paged, which
meant that it wanted to align segments on page-size boundaries.
However, all BPABI DLLs are post-processed before becoming something
that can actually be executed, so this is just wasted space in the
file.  I realized that when D_PAGED is clear, the linker will not try
to map the program headers, which means that some special-case code I
added for SymbianOS can be removed.

OK?

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-11-01  Mark Mitchell  <mark@codesourcery.com>

	* elfarm-nabi.c (elf32_arm_symbian_begin_write_processing): Clear
	D_PAGED. 
	(elf32_arm_symbian_modify_segment_map): Don't
	reset includes_filehdr and includes_phdrs here.

Index: bfd/elfarm-nabi.c
===================================================================
RCS file: /cvs/src/src/bfd/elfarm-nabi.c,v
retrieving revision 1.25
diff -c -5 -p -r1.25 elfarm-nabi.c
*** bfd/elfarm-nabi.c	19 Oct 2004 06:02:46 -0000	1.25
--- bfd/elfarm-nabi.c	1 Nov 2004 20:59:55 -0000
*************** static struct bfd_elf_special_section co
*** 972,1000 ****
  };
  
  static bfd_boolean
  elf32_arm_symbian_modify_segment_map
    PARAMS ((bfd *, struct bfd_link_info *));
  
  static bfd_boolean
  elf32_arm_symbian_modify_segment_map (abfd, info)
       bfd *abfd;
       struct bfd_link_info *info ATTRIBUTE_UNUSED;
  {
    struct elf_segment_map *m;
    asection *dynsec;
  
-   /* The first PT_LOAD segment will have the program headers and file
-      headers in it by default -- but BPABI object files should not
-      include these headers in any loadable segment.  */
-   for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
-     if (m->p_type == PT_LOAD)
-       {
- 	m->includes_filehdr = 0;
- 	m->includes_phdrs = 0;
-       }
- 
    /* BPABI shared libraries and executables should have a PT_DYNAMIC
       segment.  However, because the .dynamic section is not marked
       with SEC_LOAD, the generic ELF code will not create such a
       segment.  */
    dynsec = bfd_get_section_by_name (abfd, ".dynamic");
--- 972,1009 ----
  };
  
  static bfd_boolean
  elf32_arm_symbian_modify_segment_map
    PARAMS ((bfd *, struct bfd_link_info *));
+ static void
+ elf32_arm_symbian_begin_write_processing
+   PARAMS ((bfd *, bfd_boolean));
+ 
+ static void
+ elf32_arm_symbian_begin_write_processing (abfd, linker)
+      bfd *abfd;
+      bfd_boolean linker;
+ {
+   /* BPABI objects are never loaded directly by an OS kernel; they are
+      processed by a postlinker first, into an OS-specific format.  If
+      the D_PAGED bit is set on the file, BFD will align segments on
+      page boundaries, so that an OS can directly map the file.  With
+      BPABI objects, that just results in wasted space.  In addition,
+      because we clear the D_PAGED bit, map_sections_to_segments will
+      recognize that the program headers should not be mapped into any
+      loadable segment.  */
+   abfd->flags &= ~D_PAGED;
+ }
  
  static bfd_boolean
  elf32_arm_symbian_modify_segment_map (abfd, info)
       bfd *abfd;
       struct bfd_link_info *info ATTRIBUTE_UNUSED;
  {
    struct elf_segment_map *m;
    asection *dynsec;
  
    /* BPABI shared libraries and executables should have a PT_DYNAMIC
       segment.  However, because the .dynamic section is not marked
       with SEC_LOAD, the generic ELF code will not create such a
       segment.  */
    dynsec = bfd_get_section_by_name (abfd, ".dynamic");
*************** elf32_arm_symbian_modify_segment_map (ab
*** 1022,1031 ****
--- 1031,1044 ----
    elf32_arm_symbian_link_hash_table_create
  
  #undef elf_backend_special_sections
  #define elf_backend_special_sections elf32_arm_symbian_special_sections
  
+ #undef elf_backend_begin_write_processing
+ #define elf_backend_begin_write_processing \
+     elf32_arm_symbian_begin_write_processing
+ 
  #undef elf_backend_modify_segment_map
  #define elf_backend_modify_segment_map elf32_arm_symbian_modify_segment_map
  
  /* There is no .got section for BPABI objects, and hence no header.  */
  #undef elf_backend_got_header_size


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]