From c192a1336807cc9515666b1ba5028b6e36d91a3a Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 19 Oct 2011 04:13:28 +0000 Subject: [PATCH] PR ld/13254 include/ * bfdlink.h (struct bfd_link_info): Add error_textrel. bfd/ * elflink.c (bfd_elf_final_link): Emit error_textrel error. ld/ * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Add -z text, -z notext, -z textoff options for all targets having shared lib support. --- bfd/ChangeLog | 5 +++++ bfd/elflink.c | 11 ++++++++--- include/ChangeLog | 5 +++++ include/bfdlink.h | 3 +++ ld/ChangeLog | 7 +++++++ ld/emultempl/elf32.em | 6 ++++++ 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 3a0c0eb3709..956e3c745f6 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2011-10-19 Alan Modra + + PR ld/13254 + * elflink.c (bfd_elf_final_link): Emit error_textrel error. + 2011-10-18 David S. Miller PR binutils/13301 diff --git a/bfd/elflink.c b/bfd/elflink.c index 18aefdb5695..bd1f2f23d5c 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -11187,7 +11187,8 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) goto error_return; /* Check for DT_TEXTREL (late, in case the backend removes it). */ - if (info->warn_shared_textrel && info->shared) + if ((info->warn_shared_textrel && info->shared) + || info->error_textrel) { bfd_byte *dyncon, *dynconend; @@ -11205,8 +11206,12 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) if (dyn.d_tag == DT_TEXTREL) { - info->callbacks->einfo - (_("%P: warning: creating a DT_TEXTREL in a shared object.\n")); + if (info->error_textrel) + info->callbacks->einfo + (_("%P%X: read-only segment has dynamic relocations.\n")); + else + info->callbacks->einfo + (_("%P: warning: creating a DT_TEXTREL in a shared object.\n")); break; } } diff --git a/include/ChangeLog b/include/ChangeLog index e2d1be1ee87..b5d2d72d251 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2011-10-19 Alan Modra + + PR ld/13254 + * bfdlink.h (struct bfd_link_info): Add error_textrel. + 2011-09-28 Doug Evans * timeval-utils.h: New file. diff --git a/include/bfdlink.h b/include/bfdlink.h index c9e127c5c99..be853295ada 100644 --- a/include/bfdlink.h +++ b/include/bfdlink.h @@ -337,6 +337,9 @@ struct bfd_link_info /* TRUE if we should warn when adding a DT_TEXTREL to a shared object. */ unsigned int warn_shared_textrel: 1; + /* TRUE if we should error when adding a DT_TEXTREL. */ + unsigned int error_textrel: 1; + /* TRUE if .hash section should be created. */ unsigned int emit_hash: 1; diff --git a/ld/ChangeLog b/ld/ChangeLog index 2fbd8d1d4e0..04b8cf6e60d 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,10 @@ +2011-10-19 Alan Modra + + PR ld/13254 + * emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Add + -z text, -z notext, -z textoff options for all targets having + shared lib support. + 2011-10-15 Alan Modra * emultempl/ppc64elf.em (gld${EMULATION_NAME}_finish): Remove toc check. diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 7c8e55bb9aa..78a708bb4f0 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -2327,6 +2327,12 @@ fragment <