[vms/committed] Create an absolute section if needed
Tristan Gingold
gingold@adacore.com
Fri Jun 25 15:37:00 GMT 2010
Hi,
unlike most other object formats, absolute section must be explicitly declared. This patch makes sure
that an absolute section exists if one is referenced.
Tristan.
bfd/
2010-06-25 Tristan Gingold <gingold@adacore.com>
* vms-alpha.c (_bfd_vms_write_egsd): Check absolute section with
its flags. Create an absolute section if needed.
Index: vms-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/vms-alpha.c,v
retrieving revision 1.27
diff -c -r1.27 vms-alpha.c
*** vms-alpha.c 25 Jun 2010 15:21:48 -0000 1.27
--- vms-alpha.c 25 Jun 2010 15:35:27 -0000
***************
*** 3281,3287 ****
unsigned int symnum;
const char *sname;
flagword new_flags, old_flags;
! int abs_section_index = 0;
unsigned int target_index = 0;
struct vms_rec_wr *recwr = &PRIV (recwr);
--- 3281,3287 ----
unsigned int symnum;
const char *sname;
flagword new_flags, old_flags;
! int abs_section_index = -1;
unsigned int target_index = 0;
struct vms_rec_wr *recwr = &PRIV (recwr);
***************
*** 3344,3353 ****
else if ((*sname == 'l') && (strcmp (sname, "literal") == 0))
sname = EVAX_LITERAL_NAME;
else if ((*sname == 'l') && (strcmp (sname, "literals") == 0))
! {
! sname = EVAX_LITERALS_NAME;
! abs_section_index = section->target_index;
! }
else if ((*sname == 'c') && (strcmp (sname, "comm") == 0))
sname = EVAX_COMMON_NAME;
else if ((*sname == 'l') && (strcmp (sname, "lcomm") == 0))
--- 3344,3350 ----
else if ((*sname == 'l') && (strcmp (sname, "literal") == 0))
sname = EVAX_LITERAL_NAME;
else if ((*sname == 'l') && (strcmp (sname, "literals") == 0))
! sname = EVAX_LITERALS_NAME;
else if ((*sname == 'c') && (strcmp (sname, "comm") == 0))
sname = EVAX_COMMON_NAME;
else if ((*sname == 'l') && (strcmp (sname, "lcomm") == 0))
***************
*** 3356,3364 ****
else
sname = _bfd_vms_length_hash_symbol (abfd, sname, EOBJ__C_SECSIZ);
- _bfd_vms_output_begin_subrec (recwr, EGSD__C_PSC);
- _bfd_vms_output_short (recwr, section->alignment_power & 0xff);
-
if (bfd_is_com_section (section))
new_flags = (EGPS__V_OVR | EGPS__V_REL | EGPS__V_GBL | EGPS__V_RD
| EGPS__V_WRT | EGPS__V_NOMOD | EGPS__V_COM);
--- 3353,3358 ----
***************
*** 3377,3386 ****
--- 3371,3387 ----
vms_debug2 ((3, "new_flags %x, _raw_size %lu\n",
new_flags, (unsigned long)section->size));
+ _bfd_vms_output_begin_subrec (recwr, EGSD__C_PSC);
+ _bfd_vms_output_short (recwr, section->alignment_power & 0xff);
_bfd_vms_output_short (recwr, new_flags);
_bfd_vms_output_long (recwr, (unsigned long) section->size);
_bfd_vms_output_counted (recwr, sname);
_bfd_vms_output_end_subrec (recwr);
+
+ /* If the section is an obsolute one, remind its index as it will be
+ used later for absolute symbols. */
+ if ((new_flags & EGPS__V_REL) == 0 && abs_section_index < 0)
+ abs_section_index = section->target_index;
}
/* Output symbols. */
***************
*** 3395,3401 ****
symbol = abfd->outsymbols[symnum];
old_flags = symbol->flags;
! /* Work-around a missing feature: consider __main as the main entry point. */
if (*(symbol->name) == '_')
{
if (strcmp (symbol->name, "__main") == 0)
--- 3396,3403 ----
symbol = abfd->outsymbols[symnum];
old_flags = symbol->flags;
! /* Work-around a missing feature: consider __main as the main entry
! point. */
if (*(symbol->name) == '_')
{
if (strcmp (symbol->name, "__main") == 0)
***************
*** 3416,3429 ****
continue;
}
! /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. */
! if (_bfd_vms_output_check (recwr, 80) < 0)
{
_bfd_vms_output_end (abfd, recwr);
_bfd_vms_output_begin (recwr, EOBJ__C_EGSD);
_bfd_vms_output_long (recwr, 0);
}
_bfd_vms_output_begin_subrec (recwr, EGSD__C_SYM);
/* Data type, alignment. */
--- 3418,3449 ----
continue;
}
! /* 13 bytes egsd, max 64 chars name -> should be 77 bytes. Add 16 more
! bytes for a possible ABS section. */
! if (_bfd_vms_output_check (recwr, 80 + 16) < 0)
{
_bfd_vms_output_end (abfd, recwr);
_bfd_vms_output_begin (recwr, EOBJ__C_EGSD);
_bfd_vms_output_long (recwr, 0);
}
+ if ((old_flags & BSF_GLOBAL) != 0
+ && bfd_is_abs_section (symbol->section)
+ && abs_section_index <= 0)
+ {
+ /* Create an absolute section if none was defined. It is highly
+ unlikely that the name $ABS$ clashes with a user defined
+ non-absolute section name. */
+ _bfd_vms_output_begin_subrec (recwr, EGSD__C_PSC);
+ _bfd_vms_output_short (recwr, 4);
+ _bfd_vms_output_short (recwr, EGPS__V_SHR);
+ _bfd_vms_output_long (recwr, 0);
+ _bfd_vms_output_counted (recwr, "$ABS$");
+ _bfd_vms_output_end_subrec (recwr);
+
+ abs_section_index = target_index++;
+ }
+
_bfd_vms_output_begin_subrec (recwr, EGSD__C_SYM);
/* Data type, alignment. */
More information about the Binutils
mailing list