PR ld/12759

* emultempl/rxelf.em (ignore_lma): New variable.
	(rx_elf_create_output_section_statements): Pass the setiing of
	ignore_lma to bfd_elf32_rx_set_target_flags.
	(OPTION_IGNORE_LMA): Define.
	(OPTION_NO_IGNORE_LMA): Define.
	(PARSE_AND_LIST_LONGOPTS): Add ignore lma.
	(PARSE_AND_LIST_OPTIONS): Add ignore lma.
	(PARSE_AND_LIST_ARGS_CASES): Add ignore lma.

	* elf32-rx.c (ignore_lma): New variable.
	(bfd_elf32_rx_set_target_flags): Add ignore_lma parameter.
	(rx_modify_program_headers): Only copy the LMA into the VMA if
	ignore_lma is true.
This commit is contained in:
Nick Clifton 2011-05-17 16:02:31 +00:00
parent 393eab5450
commit 84bff83f79
4 changed files with 61 additions and 20 deletions

View file

@ -1,3 +1,11 @@
2011-05-17 Tomohiro Kashiwada <kikairoya@gmail.com>
PR ld/12759
* elf32-rx.c (ignore_lma): New variable.
(bfd_elf32_rx_set_target_flags): Add ignore_lma parameter.
(rx_modify_program_headers): Only copy the LMA into the VMA if
ignore_lma is true.
2011-05-17 Alan Modra <amodra@gmail.com> 2011-05-17 Alan Modra <amodra@gmail.com>
PR ld/12760 PR ld/12760

View file

@ -2855,13 +2855,16 @@ rx_elf_set_private_flags (bfd * abfd, flagword flags)
} }
static bfd_boolean no_warn_mismatch = FALSE; static bfd_boolean no_warn_mismatch = FALSE;
static bfd_boolean ignore_lma = TRUE;
void bfd_elf32_rx_set_target_flags (bfd_boolean); void bfd_elf32_rx_set_target_flags (bfd_boolean, bfd_boolean);
void void
bfd_elf32_rx_set_target_flags (bfd_boolean user_no_warn_mismatch) bfd_elf32_rx_set_target_flags (bfd_boolean user_no_warn_mismatch,
bfd_boolean user_ignore_lma)
{ {
no_warn_mismatch = user_no_warn_mismatch; no_warn_mismatch = user_no_warn_mismatch;
ignore_lma = user_ignore_lma;
} }
/* Merge backend specific data from an object file to the output /* Merge backend specific data from an object file to the output
@ -3332,7 +3335,8 @@ elf32_rx_modify_program_headers (bfd * abfd ATTRIBUTE_UNUSED,
phdr = tdata->phdr; phdr = tdata->phdr;
count = tdata->program_header_size / bed->s->sizeof_phdr; count = tdata->program_header_size / bed->s->sizeof_phdr;
for (i = count; i-- != 0; ) if (ignore_lma)
for (i = count; i-- != 0;)
if (phdr[i].p_type == PT_LOAD) if (phdr[i].p_type == PT_LOAD)
{ {
/* The Renesas tools expect p_paddr to be zero. However, /* The Renesas tools expect p_paddr to be zero. However,
@ -3344,9 +3348,10 @@ elf32_rx_modify_program_headers (bfd * abfd ATTRIBUTE_UNUSED,
does not affect the section headers, just the program does not affect the section headers, just the program
headers. We hope. */ headers. We hope. */
phdr[i].p_vaddr = phdr[i].p_paddr; phdr[i].p_vaddr = phdr[i].p_paddr;
/* If we zero out p_paddr, then the LMA in the section table #if 0 /* If we zero out p_paddr, then the LMA in the section table
becomes wrong. */ becomes wrong. */
/*phdr[i].p_paddr = 0;*/ phdr[i].p_paddr = 0;
#endif
} }
return TRUE; return TRUE;

View file

@ -1,3 +1,15 @@
2011-05-17 Tomohiro Kashiwada <kikairoya@gmail.com>
PR ld/12759
* emultempl/rxelf.em (ignore_lma): New variable.
(rx_elf_create_output_section_statements): Pass the setiing of
ignore_lma to bfd_elf32_rx_set_target_flags.
(OPTION_IGNORE_LMA): Define.
(OPTION_NO_IGNORE_LMA): Define.
(PARSE_AND_LIST_LONGOPTS): Add ignore lma.
(PARSE_AND_LIST_OPTIONS): Add ignore lma.
(PARSE_AND_LIST_ARGS_CASES): Add ignore lma.
2011-05-17 Alan Modra <amodra@gmail.com> 2011-05-17 Alan Modra <amodra@gmail.com>
PR ld/12760 PR ld/12760

View file

@ -1,5 +1,5 @@
# This shell script emits a C file. -*- C -*- # This shell script emits a C file. -*- C -*-
# Copyright 2009 Free Software Foundation, Inc. # Copyright 2009, 2011 Free Software Foundation, Inc.
# #
# This file is part of the GNU Binutils. # This file is part of the GNU Binutils.
# #
@ -26,15 +26,16 @@ test -z "$TARGET2_TYPE" && TARGET2_TYPE="rel"
fragment <<EOF fragment <<EOF
static bfd_boolean no_flag_mismatch_warnings = FALSE; static bfd_boolean no_flag_mismatch_warnings = FALSE;
static bfd_boolean ignore_lma = TRUE;
/* This is a convenient point to tell BFD about target specific flags. /* This is a convenient point to tell BFD about target specific flags.
After the output has been created, but before inputs are read. */ After the output has been created, but before inputs are read. */
static void static void
rx_elf_create_output_section_statements (void) rx_elf_create_output_section_statements (void)
{ {
extern void bfd_elf32_rx_set_target_flags (bfd_boolean); extern void bfd_elf32_rx_set_target_flags (bfd_boolean, bfd_boolean);
bfd_elf32_rx_set_target_flags (no_flag_mismatch_warnings); bfd_elf32_rx_set_target_flags (no_flag_mismatch_warnings, ignore_lma);
} }
EOF EOF
@ -44,21 +45,36 @@ EOF
# #
PARSE_AND_LIST_PROLOGUE=' PARSE_AND_LIST_PROLOGUE='
#define OPTION_NO_FLAG_MISMATCH_WARNINGS 301 #define OPTION_NO_FLAG_MISMATCH_WARNINGS 301
#define OPTION_IGNORE_LMA 302
#define OPTION_NO_IGNORE_LMA 303
' '
PARSE_AND_LIST_LONGOPTS=' PARSE_AND_LIST_LONGOPTS='
{ "no-flag-mismatch-warnings", no_argument, NULL, OPTION_NO_FLAG_MISMATCH_WARNINGS}, { "no-flag-mismatch-warnings", no_argument, NULL, OPTION_NO_FLAG_MISMATCH_WARNINGS},
{ "ignore-lma", no_argument, NULL, OPTION_IGNORE_LMA},
{ "no-ignore-lma", no_argument, NULL, OPTION_NO_IGNORE_LMA},
' '
PARSE_AND_LIST_OPTIONS=' PARSE_AND_LIST_OPTIONS='
fprintf (file, _(" --no-flag-mismatch-warnings Don'\''t warn about objects with incompatible" fprintf (file, _(" --no-flag-mismatch-warnings Don'\''t warn about objects with incompatible\n"
" endian or dsp settings\n")); " endian or dsp settings\n"));
fprintf (file, _(" --ignore-lma Ignore segment LMAs [default]\n"
" (for Renesas Tools compatibility)\n"));
fprintf (file, _(" --no-ignore-lma Don'\''t ignore segment LMAs\n"));
' '
PARSE_AND_LIST_ARGS_CASES=' PARSE_AND_LIST_ARGS_CASES='
case OPTION_NO_FLAG_MISMATCH_WARNINGS: case OPTION_NO_FLAG_MISMATCH_WARNINGS:
no_flag_mismatch_warnings = TRUE; no_flag_mismatch_warnings = TRUE;
break; break;
case OPTION_IGNORE_LMA:
ignore_lma = TRUE;
break;
case OPTION_NO_IGNORE_LMA:
ignore_lma = FALSE;
break;
' '
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=rx_elf_create_output_section_statements LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=rx_elf_create_output_section_statements