to permit it and -ztext to reenable the default of forbidding it.
ok kettenis@
goto error_return;
/* Check for DT_TEXTREL (late, in case the backend removes it). */
- if (info->warn_shared_textrel && info->shared)
+ if (!info->allow_textrel || (info->warn_shared_textrel && info->shared))
{
bfd_byte *dyncon, *dynconend;
/* Fix up .dynamic entries. */
o = bfd_get_section_by_name (dynobj, ".dynamic");
- BFD_ASSERT (o != NULL);
-
- dyncon = o->contents;
- dynconend = o->contents + o->size;
- for (; dyncon < dynconend; dyncon += bed->s->sizeof_dyn)
+ if (o != NULL)
{
- Elf_Internal_Dyn dyn;
+ dyncon = o->contents;
+ dynconend = o->contents + o->size;
+ for (; dyncon < dynconend; dyncon += bed->s->sizeof_dyn)
+ {
+ Elf_Internal_Dyn dyn;
- bed->s->swap_dyn_in (dynobj, dyncon, &dyn);
+ bed->s->swap_dyn_in (dynobj, dyncon, &dyn);
- if (dyn.d_tag == DT_TEXTREL)
- {
- _bfd_error_handler
- (_("warning: creating a DT_TEXTREL in a shared object."));
- break;
+ if (dyn.d_tag == DT_TEXTREL)
+ {
+ _bfd_error_handler
+ (_("warning: creating a DT_TEXTREL in a shared object."));
+ if (!info->allow_textrel)
+ goto error_return;
+ break;
+ }
}
}
}
/* TRUE if ok to have version with no definition. */
unsigned int allow_undefined_version: 1;
+ /* TRUE if ok to have text relocations. */
+ unsigned int allow_textrel: 1;
+
/* TRUE if a default symbol version should be created and used for
exported symbols. */
unsigned int create_default_symver: 1;
link_info.relro = FALSE;
else if (strcmp (optarg, "wxneeded") == 0)
link_info.wxneeded = TRUE;
+ else if (strcmp (optarg, "notext") == 0)
+ link_info.allow_textrel = TRUE;
+ else if (strcmp (optarg, "text") == 0)
+ link_info.allow_textrel = FALSE;
/* What about the other Solaris -z options? FIXME. */
break;
EOF
@item norelro
Don't create an ELF @code{PT_GNU_RELRO} segment header in the object.
+@item notext
+Permit creation of objects with text relocations.
+
@item now
When generating an executable or shared library, mark it to tell the
dynamic linker to resolve all symbols when the program is started, or
deferring function call resolution to the point when the function is
first called.
-@item wxneeded
-Marks the executable with a @code{PT_OPENBSD_WXNEEDED} segment header,
-indicating it is expected to perform W^X violating operations later
-(such as calling mprotect(2) or mmap(2) with both PROT_WRITE and PROT_EXEC).
-
@item origin
Marks the object may contain $ORIGIN.
@item relro
Create an ELF @code{PT_GNU_RELRO} segment header in the object.
+@item text
+Make creation of objects with text relocations a fatal error.
+This is the default.
+
+@item wxneeded
+Marks the executable with a @code{PT_OPENBSD_WXNEEDED} segment header,
+indicating it is expected to perform W^X violating operations later
+(such as calling mprotect(2) or mmap(2) with both PROT_WRITE and PROT_EXEC).
+
@end table
Other keywords are ignored for Solaris compatibility.
link_info.unresolved_syms_in_shared_libs = RM_NOT_YET_SET;
link_info.allow_multiple_definition = FALSE;
link_info.allow_undefined_version = TRUE;
+ link_info.allow_textrel = FALSE;
link_info.create_default_symver = FALSE;
link_info.default_imported_symver = FALSE;
link_info.keep_memory = TRUE;