[PATCH] Fix tst-array* on x86_64

H. J. Lu hjl@lucon.org
Tue Dec 10 15:44:00 GMT 2002


On Tue, Dec 10, 2002 at 03:25:38PM -0800, Roland McGrath wrote:
> > Why are the labels around wrong?  I would imagine that padding is added
> > and that if two .preinit_array sections have to be concatenated there is
> > garbage between them.  But still, the lables should be rights.
> 
> This padding is added by the compiler, inside the section.  
> The labels are created by the linker.  i.e.: 
> 
> .globl preinit_array
> 	.section	.preinit_array,"a",@progbits
> 	.align 16
> 	.type	preinit_array, @object
> 	.size	preinit_array, 24
> preinit_array:
> 	.quad ...
> 
> This doesn't explain exactly what I saw, which was the linker symbols and
> the sections not starting at the same address.  But even if they matched,
> the leading or trailing zeros bite.

Does

  /* Ensure the __preinit_array_start label is properly aligned.  We
     could instead move the label definition inside the section, but
     the linker would then create the section even if it turns out to
     be empty, which isn't pretty.  */
  ${RELOCATING+. = ALIGN(${ALIGNMENT});}
  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_start = .);}}
  .preinit_array   ${RELOCATING-0} : { *(.preinit_array) }
  ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_end = .);}}

explain what you saw?


H.J.



More information about the Libc-hacker mailing list