Don't set DT_TEXTREL flag for Xtensa

Bob Wilson bwilson@tensilica.com
Tue Mar 23 12:34:00 GMT 2004


Use of the DT_TEXTREL dynamic entry for Xtensa shared objects is not compatible 
with the way the Xtensa runtime loader handles literal pools.  The literal pools 
are located within the text section, and the loader reads a special "literal 
table" to locate the literal pools and make them writable.  If the DT_TEXTREL 
flag is set, the entire text section reverts to being read-only after the 
initial relocations have been performed, thereby undoing the protection changes 
for pages containing literal pools.  This problem went undetected for quite a 
while because it was masked by a bug in the Xtensa port of the 2.4 Linux kernel.

This patch changes the assembler to always emit literal table entries, even when 
using the --text-section-literals assembler option.  The previous plan was to 
handle --text-section-literals by setting DT_TEXTREL.  With this patch, code 
assembled with --text-section-literals will at least work, even if the literal 
tables are larger than one would like.  I'm not very concerned about this 
because it doesn't really make much sense to use --text-section-literals on a 
system with shared objects, anyway.  I'm thinking of some ways to clean this up 
in the longer term.

The patch also changes the linker to make it stop setting DT_TEXTREL when it 
encounters a relocation on a read-only section and outside a literal pool. 
Instead, it now checks the literal tables when emitting dynamic relocations, and 
  if there is a dynamic relocation outside a literal pool, it is treated as an 
error.

I tested this by running the testsuite with an xtensa-elf target (no shared 
libraries), and by building glibc and booting a board with it.  Committed on the 
mainline and 2.15 branch.


bfd/ChangeLog:

	* elf32-xtensa.c (elf_xtensa_check_relocs): Remove code to read
	literal tables and check for relocs outside of literal pools.
	(elf_xtensa_make_sym_local): Don't clear ELF_LINK_NON_GOT_REF flag.
	(elf_xtensa_fix_refcounts): Don't check ELF_LINK_NON_GOT_REF or
	set DF_TEXTREL.
	(elf_xtensa_size_dynamic_sections): Don't add DT_TEXTREL entry.
	(elf_xtensa_relocate_section): Read literal tables and check for
	dynamic relocations in read-only sections and not in literal pools.

gas/ChangeLog:

	* config/tc-xtensa.c (xtensa_post_relax_hook): Create literal
	tables even when use_literal_section flag is not set.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bfd-notextrel.diff
URL: <https://sourceware.org/pipermail/binutils/attachments/20040323/ee4b1276/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gas-notextrel.diff
URL: <https://sourceware.org/pipermail/binutils/attachments/20040323/ee4b1276/attachment-0001.ksh>


More information about the Binutils mailing list