#3260: Linking stage2 on PPC gives "scattered reloc r_address too large"
---------------------------------+------------------------------------------
    Reporter:  benl              |        Owner:              
        Type:  bug               |       Status:  new         
    Priority:  normal            |    Milestone:  _|_         
   Component:  Compiler          |      Version:  6.13        
    Keywords:                    |   Difficulty:  Unknown     
          Os:  MacOS X           |     Testcase:              
Architecture:  Unknown/Multiple  |      Failure:  None/Unknown
---------------------------------+------------------------------------------

Comment(by PHO):

 > Does anyone know why Mach-O has this limit on segment sizes for .o
 files, but not for shared libraries?

 I think I can explain this.

 First of all, I have to apologize that my previous explanation was
 inaccurate.

 1. The size limitation applies to sections, not segments.
 2. ld(1) complains about sections larger than 2^24^ - 1 bytes ''if and
 only if'' there exists a scattered relocation entry whose r_address points
 to such sections.

 Look at the load commands of libHSghc-*.dylib. This dylib actually has a
 large section:
 {{{
 % otool -l
 compiler/stage2/build/libHSghc-6.13.20100516-ghc6.13.20100516.dylib
 compiler/stage2/build/libHSghc-6.13.20100516-ghc6.13.20100516.dylib:
 Load command 0
       cmd LC_SEGMENT
   cmdsize 260
   segname __TEXT
    vmaddr 0x00000000
    vmsize 0x0181d000
   fileoff 0
  filesize 25284608
   maxprot 0x00000007
  initprot 0x00000005
    nsects 3
     flags 0x0
 Section
   sectname __text
    segname __TEXT
       addr 0x00001240
       size 0x01701fbc   // <- Larger than 2^24 - 1 bytes!
     offset 4672
      align 2^4 (16)
     reloff 0
     nreloc 0
      flags 0x80000400
  reserved1 0
  reserved2 0
 ...
 }}}

 But since dynamic libraries are position-independent, every references
 to external segments (or external libraries) are indirectly referred
 using symbol pointers. Since symbol pointers are located in the same
 segment at which the referring !__text section is located, no scattered
 relocations are needed for them. Thus it's not really a problem to
 have large sections for dynamic libraries.

 {{{
 % otool -rv
 compiler/stage2/build/libHSghc-6.13.20100516-ghc6.13.20100516.dylib | awk
 '{print $5}' | sort | uniq

 VANILLA  // <- There are no relocation entries with types other than
 VANILLA.
 entries
 type
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3260#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to