public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: Reduce size of SymbianOS DLLs
@ 2004-11-01 21:10 Mark Mitchell
  2004-11-02 10:29 ` Richard Earnshaw
  2004-11-03 17:24 ` Richard Earnshaw
  0 siblings, 2 replies; 22+ messages in thread
From: Mark Mitchell @ 2004-11-01 21:10 UTC (permalink / raw)
  To: binutils


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

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2004-11-04  8:52 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-01 21:10 PATCH: Reduce size of SymbianOS DLLs Mark Mitchell
2004-11-02 10:29 ` Richard Earnshaw
2004-11-02 14:56   ` Ian Lance Taylor
2004-11-02 15:04     ` Richard Earnshaw
2004-11-02 15:08       ` Ian Lance Taylor
2004-11-02 15:11         ` Richard Earnshaw
2004-11-02 15:17       ` Daniel Jacobowitz
2004-11-02 15:21         ` Richard Earnshaw
2004-11-02 15:29           ` Nick Clifton
2004-11-02 15:33             ` Richard Earnshaw
2004-11-02 15:43               ` Nick Clifton
2004-11-02 16:24                 ` Mark Mitchell
2004-11-02 16:31                   ` Daniel Jacobowitz
2004-11-02 16:42                     ` Mark Mitchell
2004-11-03 15:05                       ` Obsoleting elfarm-oabi [was Re: PATCH: Reduce size of SymbianOS DLLs] Richard Earnshaw
2004-11-03 15:25                         ` Nick Clifton
2004-11-03 15:57                         ` Richard Earnshaw
2004-11-04  8:52                           ` Nick Clifton
2004-11-02 17:44                     ` PATCH: Reduce size of SymbianOS DLLs Mark Mitchell
2004-11-02 15:59               ` Daniel Jacobowitz
2004-11-02 16:01                 ` Richard Earnshaw
2004-11-03 17:24 ` Richard Earnshaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).