Compare commits

...

3 Commits

Author SHA1 Message Date
H.J. Lu
9acd786df4 Place .shstrtab before debug sections 2015-04-20 12:57:30 -07:00
H.J. Lu
c923726a88 Delay .shstrtab 2015-04-20 12:57:30 -07:00
H.J. Lu
05570de228 Don't change compressed input debug section names
Change compressed input debug section name for objdump is very confusing.
But we need to change it for linker so that linker will consider the
input section as a debug section.  This patch delays section rename to
elf_fake_sections for objcopy and avoids it for objdump.

bfd/

	PR binutils/18209
	* bfd.c (bfd): Add is_linker_input.
	* elf.c (convert_debug_to_zdebug): New.
	(convert_zdebug_to_debug): Likewise.
	(_bfd_elf_make_section_from_shdr): Don't convert .debug_* to
	.zdebug_* here.  Use convert_zdebug_to_debug.  Set SEC_ELF_RENAME.
	(_bfd_elf_init_reloc_shdr): Pass a pointer to section name
	instead of a pointer to section.
	(elf_fake_sections): Rename the section name if SEC_ELF_RENAME
	is set.
	* section.c (SEC_ELF_RENAME): New.
	* bfd-in2.h: Regenerated.

binutils/

	PR binutils/18209
	* objcopy.c (setup_section): Copy compress status.

binutils/testsuite/

	PR binutils/18209
	* binutils-all/compress.exp: Replace dw2-3.W with dw2-3gabi.W
	on zlib-gabi output.
	* binutils-all/dw2-1.W: Convert section names to .zdebug_*.
	* binutils-all/dw2-3.W: Likewise.
	* binutils-all/objdump.W: Likewise.
	* binutils-all/dw2-3gabi.W: New file.

ld/

	PR binutils/18209
	* ldfile.c (ldfile_try_open_bfd): Set is_linker_input to 1.
2015-04-20 12:53:43 -07:00
14 changed files with 423 additions and 116 deletions

View File

@@ -1400,6 +1400,10 @@ typedef struct bfd_section
TMS320C54X only. */
#define SEC_TIC54X_BLOCK 0x10000000
/* This section should be renamed. This is for ELF linker
internal use only. */
#define SEC_ELF_RENAME 0x10000000
/* Conditionally link this section; do not link if there are no
references found to any symbol in the section. This is for TI
TMS320C54X only. */
@@ -6465,6 +6469,9 @@ struct bfd
/* Set if this is the linker output BFD. */
unsigned int is_linker_output : 1;
/* Set if this is the linker input BFD. */
unsigned int is_linker_input : 1;
/* If this is an input for a compiler plug-in library. */
ENUM_BITFIELD (bfd_plugin_format) plugin_format : 2;

View File

@@ -212,6 +212,9 @@ CODE_FRAGMENT
. {* Set if this is the linker output BFD. *}
. unsigned int is_linker_output : 1;
.
. {* Set if this is the linker input BFD. *}
. unsigned int is_linker_input : 1;
.
. {* If this is an input for a compiler plug-in library. *}
. ENUM_BITFIELD (bfd_plugin_format) plugin_format : 2;
.

View File

@@ -72,8 +72,7 @@ decompress_contents (bfd_byte *compressed_buffer,
static bfd_size_type
bfd_compress_section_contents (bfd *abfd, sec_ptr sec,
bfd_byte *uncompressed_buffer,
bfd_size_type uncompressed_size,
bfd_boolean write_compress)
bfd_size_type uncompressed_size)
{
uLong compressed_size;
bfd_byte *buffer;
@@ -177,11 +176,8 @@ bfd_compress_section_contents (bfd *abfd, sec_ptr sec,
compressed_size += header_size;
/* PR binutils/18087: If compression didn't make the section smaller,
just keep it uncompressed. We always generate .zdebug_* section
when linking since section names have been finalized and they
can't be changed easily. */
if ((write_compress && compression_header_size == 0)
|| compressed_size < uncompressed_size)
just keep it uncompressed. */
if (compressed_size < uncompressed_size)
{
bfd_update_compression_header (abfd, buffer, sec);
@@ -547,8 +543,7 @@ bfd_init_section_compress_status (bfd *abfd, sec_ptr sec)
{
uncompressed_size = bfd_compress_section_contents (abfd, sec,
uncompressed_buffer,
uncompressed_size,
FALSE);
uncompressed_size);
ret = uncompressed_size != 0;
}
@@ -590,5 +585,5 @@ bfd_compress_section (bfd *abfd, sec_ptr sec, bfd_byte *uncompressed_buffer)
/* Compress it. */
return bfd_compress_section_contents (abfd, sec, uncompressed_buffer,
uncompressed_size, TRUE) != 0;
uncompressed_size) != 0;
}

312
bfd/elf.c
View File

@@ -855,6 +855,31 @@ bfd_elf_is_group_section (bfd *abfd ATTRIBUTE_UNUSED, const asection *sec)
return elf_next_in_group (sec) != NULL;
}
static char *
convert_debug_to_zdebug (bfd *abfd, const char *name)
{
unsigned int len = strlen (name);
char *new_name = bfd_alloc (abfd, len + 2);
if (new_name == NULL)
return NULL;
new_name[0] = '.';
new_name[1] = 'z';
memcpy (new_name + 2, name + 1, len);
return new_name;
}
static char *
convert_zdebug_to_debug (bfd *abfd, const char *name)
{
unsigned int len = strlen (name);
char *new_name = bfd_alloc (abfd, len);
if (new_name == NULL)
return NULL;
new_name[0] = '.';
memcpy (new_name + 1, name + 2, len - 1);
return new_name;
}
/* Make a BFD section from an ELF section. We store a pointer to the
BFD section in the bfd_section field of the header. */
@@ -1041,7 +1066,6 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
|| (name[1] == 'z' && name[7] == '_')))
{
enum { nothing, compress, decompress } action = nothing;
char *new_name;
int compression_header_size;
bfd_boolean compressed
= bfd_is_section_compressed_with_header (abfd, newsect,
@@ -1090,42 +1114,26 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
}
}
new_name = NULL;
if (action == decompress
|| (action == compress
&& (abfd->flags & BFD_COMPRESS_GABI) != 0))
if (abfd->is_linker_input)
{
if (name[1] == 'z')
if (name[1] == 'z'
&& (action == decompress
|| (action == compress
&& (abfd->flags & BFD_COMPRESS_GABI) != 0)))
{
unsigned int len = strlen (name);
new_name = bfd_alloc (abfd, len);
/* Convert section name from .zdebug_* to .debug_* so
that linker will consider this section as a debug
section. */
char *new_name = convert_zdebug_to_debug (abfd, name);
if (new_name == NULL)
return FALSE;
new_name[0] = '.';
memcpy (new_name + 1, name + 2, len - 1);
bfd_rename_section (abfd, newsect, new_name);
}
}
else if (action == compress
&& newsect->compress_status == COMPRESS_SECTION_DONE)
{
/* PR binutils/18087: Compression does not always make a section
smaller. So only rename the section when compression has
actually taken place. */
if (name[1] != 'z')
{
unsigned int len = strlen (name);
new_name = bfd_alloc (abfd, len + 2);
if (new_name == NULL)
return FALSE;
new_name[0] = '.';
new_name[1] = 'z';
memcpy (new_name + 2, name + 1, len);
}
}
if (new_name != NULL)
bfd_rename_section (abfd, newsect, new_name);
else
/* For objdump, don't rename the section. For objcopy, delay
section rename to elf_fake_sections. */
newsect->flags |= SEC_ELF_RENAME;
}
return TRUE;
@@ -2681,6 +2689,27 @@ _bfd_elf_single_rel_hdr (asection *sec)
return elf_section_data (sec)->rela.hdr;
}
static bfd_boolean
_bfd_elf_set_reloc_sh_name (bfd *abfd,
Elf_Internal_Shdr *rel_hdr,
const char *sec_name,
bfd_boolean use_rela_p)
{
char *name = (char *) bfd_alloc (abfd,
sizeof ".rela" + strlen (sec_name));
if (name == NULL)
return FALSE;
sprintf (name, "%s%s", use_rela_p ? ".rela" : ".rel", sec_name);
rel_hdr->sh_name =
(unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd), name,
FALSE);
if (rel_hdr->sh_name == (unsigned int) -1)
return FALSE;
return TRUE;
}
/* Allocate and initialize a section-header for a new reloc section,
containing relocations against ASECT. It is stored in RELDATA. If
USE_RELA_P is TRUE, we use RELA relocations; otherwise, we use REL
@@ -2689,11 +2718,11 @@ _bfd_elf_single_rel_hdr (asection *sec)
static bfd_boolean
_bfd_elf_init_reloc_shdr (bfd *abfd,
struct bfd_elf_section_reloc_data *reldata,
asection *asect,
bfd_boolean use_rela_p)
const char *sec_name,
bfd_boolean use_rela_p,
bfd_boolean delay_st_name_p)
{
Elf_Internal_Shdr *rel_hdr;
char *name;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
bfd_size_type amt;
@@ -2702,15 +2731,10 @@ _bfd_elf_init_reloc_shdr (bfd *abfd,
rel_hdr = bfd_zalloc (abfd, amt);
reldata->hdr = rel_hdr;
amt = sizeof ".rela" + strlen (asect->name);
name = (char *) bfd_alloc (abfd, amt);
if (name == NULL)
return FALSE;
sprintf (name, "%s%s", use_rela_p ? ".rela" : ".rel", asect->name);
rel_hdr->sh_name =
(unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd), name,
FALSE);
if (rel_hdr->sh_name == (unsigned int) -1)
if (delay_st_name_p)
rel_hdr->sh_name = (unsigned int) -1;
else if (!_bfd_elf_set_reloc_sh_name (abfd, rel_hdr, sec_name,
use_rela_p))
return FALSE;
rel_hdr->sh_type = use_rela_p ? SHT_RELA : SHT_REL;
rel_hdr->sh_entsize = (use_rela_p
@@ -2753,6 +2777,7 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
Elf_Internal_Shdr *this_hdr;
unsigned int sh_type;
const char *name = asect->name;
bfd_boolean delay_st_name_p = FALSE;
if (arg->failed)
{
@@ -2763,42 +2788,72 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
this_hdr = &esd->this_hdr;
/* For linking, compress DWARF debug sections with names: .debug_*. */
if (arg->link_info
&& (arg->link_info->compress_debug & COMPRESS_DEBUG)
&& (asect->flags & SEC_DEBUGGING)
&& name[1] == 'd'
&& name[6] == '_')
if (arg->link_info)
{
/* Set SEC_ELF_COMPRESS to indicate this section should be
compressed. */
asect->flags |= SEC_ELF_COMPRESS;
if (arg->link_info->compress_debug != COMPRESS_DEBUG_GABI_ZLIB)
/* ld: compress DWARF debug sections with names: .debug_*. */
if ((arg->link_info->compress_debug & COMPRESS_DEBUG)
&& (asect->flags & SEC_DEBUGGING)
&& name[1] == 'd'
&& name[6] == '_')
{
/* If SHF_COMPRESSED isn't used, rename compressed DWARF
debug section to .zdebug_*. */
unsigned int len = strlen (name);
char *new_name = bfd_alloc (abfd, len + 2);
/* Set SEC_ELF_COMPRESS to indicate this section should be
compressed. */
asect->flags |= SEC_ELF_COMPRESS;
/* If this section will be compressed, delay adding setion
name to section name section after it is compressed in
_bfd_elf_assign_file_positions_for_non_load. */
delay_st_name_p = TRUE;
}
}
else if ((asect->flags & SEC_ELF_RENAME))
{
/* objcopy: rename output DWARF debug section. */
if ((abfd->flags & (BFD_DECOMPRESS | BFD_COMPRESS_GABI)))
{
/* When we decompress or compress with SHF_COMPRESSED,
convert section name from .zdebug_* to .debug_* if
needed. */
if (name[1] == 'z')
{
char *new_name = convert_zdebug_to_debug (abfd, name);
if (new_name == NULL)
{
arg->failed = TRUE;
return;
}
name = new_name;
}
}
else if (asect->compress_status == COMPRESS_SECTION_DONE)
{
/* PR binutils/18087: Compression does not always make a
section smaller. So only rename the section when
compression has actually taken place. If input section
name is .zdebug_*, we should never compress it again. */
char *new_name = convert_debug_to_zdebug (abfd, name);
if (new_name == NULL)
{
arg->failed = TRUE;
return;
}
new_name[0] = '.';
new_name[1] = 'z';
memcpy (new_name + 2, name + 1, len);
bfd_rename_section (abfd, asect, new_name);
name = asect->name;
BFD_ASSERT (name[1] != 'z');
name = new_name;
}
}
this_hdr->sh_name = (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd),
name, FALSE);
if (this_hdr->sh_name == (unsigned int) -1)
if (delay_st_name_p)
this_hdr->sh_name = (unsigned int) -1;
else
{
arg->failed = TRUE;
return;
this_hdr->sh_name
= (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd),
name, FALSE);
if (this_hdr->sh_name == (unsigned int) -1)
{
arg->failed = TRUE;
return;
}
}
/* Don't clear sh_flags. Assembler may set additional bits. */
@@ -2972,13 +3027,15 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
&& (arg->link_info->relocatable || arg->link_info->emitrelocations))
{
if (esd->rel.count && esd->rel.hdr == NULL
&& !_bfd_elf_init_reloc_shdr (abfd, &esd->rel, asect, FALSE))
&& !_bfd_elf_init_reloc_shdr (abfd, &esd->rel, name, FALSE,
delay_st_name_p))
{
arg->failed = TRUE;
return;
}
if (esd->rela.count && esd->rela.hdr == NULL
&& !_bfd_elf_init_reloc_shdr (abfd, &esd->rela, asect, TRUE))
&& !_bfd_elf_init_reloc_shdr (abfd, &esd->rela, name, TRUE,
delay_st_name_p))
{
arg->failed = TRUE;
return;
@@ -2987,8 +3044,9 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
else if (!_bfd_elf_init_reloc_shdr (abfd,
(asect->use_rela_p
? &esd->rela : &esd->rel),
asect,
asect->use_rela_p))
name,
asect->use_rela_p,
delay_st_name_p))
arg->failed = TRUE;
}
@@ -3173,7 +3231,7 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
{
struct elf_obj_tdata *t = elf_tdata (abfd);
asection *sec;
unsigned int section_number, secn;
unsigned int section_number;
Elf_Internal_Shdr **i_shdrp;
struct bfd_elf_section_data *d;
bfd_boolean need_symtab;
@@ -3210,11 +3268,13 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
if (d->this_hdr.sh_type != SHT_GROUP)
d->this_idx = section_number++;
_bfd_elf_strtab_addref (elf_shstrtab (abfd), d->this_hdr.sh_name);
if (d->this_hdr.sh_name != (unsigned int) -1)
_bfd_elf_strtab_addref (elf_shstrtab (abfd), d->this_hdr.sh_name);
if (d->rel.hdr)
{
d->rel.idx = section_number++;
_bfd_elf_strtab_addref (elf_shstrtab (abfd), d->rel.hdr->sh_name);
if (d->rel.hdr->sh_name != (unsigned int) -1)
_bfd_elf_strtab_addref (elf_shstrtab (abfd), d->rel.hdr->sh_name);
}
else
d->rel.idx = 0;
@@ -3222,7 +3282,8 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
if (d->rela.hdr)
{
d->rela.idx = section_number++;
_bfd_elf_strtab_addref (elf_shstrtab (abfd), d->rela.hdr->sh_name);
if (d->rela.hdr->sh_name != (unsigned int) -1)
_bfd_elf_strtab_addref (elf_shstrtab (abfd), d->rela.hdr->sh_name);
}
else
d->rela.idx = 0;
@@ -3260,9 +3321,6 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
return FALSE;
}
_bfd_elf_strtab_finalize (elf_shstrtab (abfd));
t->shstrtab_hdr.sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd));
elf_numsections (abfd) = section_number;
elf_elfheader (abfd)->e_shnum = section_number;
@@ -3478,9 +3536,10 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
}
}
for (secn = 1; secn < section_number; ++secn)
i_shdrp[secn]->sh_name = _bfd_elf_strtab_offset (elf_shstrtab (abfd),
i_shdrp[secn]->sh_name);
/* Delay setting sh_name to _bfd_elf_write_object_contents so that
_bfd_elf_assign_file_positions_for_non_load can convert DWARF
debug section name from .debug_* to .zdebug_* if needed. */
return TRUE;
}
@@ -3737,7 +3796,7 @@ _bfd_elf_compute_section_file_positions (bfd *abfd,
shstrtab_hdr->sh_entsize = 0;
shstrtab_hdr->sh_link = 0;
shstrtab_hdr->sh_info = 0;
/* sh_offset is set in assign_file_positions_except_relocs. */
/* sh_offset is set in _bfd_elf_assign_file_positions_for_non_load. */
shstrtab_hdr->sh_addralign = 1;
if (!assign_file_positions_except_relocs (abfd, link_info))
@@ -5147,7 +5206,8 @@ assign_file_positions_for_non_load_sections (bfd *abfd,
/* Compress DWARF debug sections. */
|| hdr == i_shdrpp[elf_onesymtab (abfd)]
|| hdr == i_shdrpp[elf_symtab_shndx (abfd)]
|| hdr == i_shdrpp[elf_strtab_sec (abfd)])
|| hdr == i_shdrpp[elf_strtab_sec (abfd)]
|| hdr == i_shdrpp[elf_shstrtab_sec (abfd)])
hdr->sh_offset = -1;
else
off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);
@@ -5400,7 +5460,8 @@ assign_file_positions_except_relocs (bfd *abfd,
/* Compress DWARF debug sections. */
|| i == elf_onesymtab (abfd)
|| i == elf_symtab_shndx (abfd)
|| i == elf_strtab_sec (abfd))
|| i == elf_strtab_sec (abfd)
|| i == elf_shstrtab_sec (abfd))
{
hdr->sh_offset = -1;
}
@@ -5555,7 +5616,8 @@ static bfd_boolean
_bfd_elf_assign_file_positions_for_non_load (bfd *abfd)
{
file_ptr off;
Elf_Internal_Shdr **shdrpp, **end_shdrpp;
Elf_Internal_Shdr **shdrpp, **end_shdrpp, **debug_shdrpp = NULL;
Elf_Internal_Shdr *shdrp;
Elf_Internal_Ehdr *i_ehdrp;
const struct elf_backend_data *bed;
@@ -5565,36 +5627,89 @@ _bfd_elf_assign_file_positions_for_non_load (bfd *abfd)
end_shdrpp = shdrpp + elf_numsections (abfd);
for (shdrpp++; shdrpp < end_shdrpp; shdrpp++)
{
Elf_Internal_Shdr *shdrp;
shdrp = *shdrpp;
if (shdrp->sh_offset == -1)
{
asection *sec = shdrp->bfd_section;
bfd_boolean is_rel = (shdrp->sh_type == SHT_REL
|| shdrp->sh_type == SHT_RELA);
if (is_rel
|| (shdrp->bfd_section != NULL
&& (shdrp->bfd_section->flags & SEC_ELF_COMPRESS)))
|| (sec != NULL && (sec->flags & SEC_ELF_COMPRESS)))
{
if (!is_rel)
{
const char *name = sec->name;
struct bfd_elf_section_data *d;
/* Compress DWARF debug sections. */
if (!bfd_compress_section (abfd, shdrp->bfd_section,
if (!bfd_compress_section (abfd, sec,
shdrp->contents))
return FALSE;
if (sec->compress_status == COMPRESS_SECTION_DONE
&& (abfd->flags & BFD_COMPRESS_GABI) == 0)
{
/* If section is compressed with zlib-gnu, convert
section name from .debug_* to .zdebug_*. */
char *new_name
= convert_debug_to_zdebug (abfd, name);
if (new_name == NULL)
return FALSE;
name = new_name;
}
/* Add setion name to section name section. */
if (shdrp->sh_name != (unsigned int) -1)
abort ();
shdrp->sh_name
= (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd),
name, FALSE);
d = elf_section_data (sec);
/* Add reloc setion name to section name section. */
if (d->rel.hdr
&& !_bfd_elf_set_reloc_sh_name (abfd,
d->rel.hdr,
name, FALSE))
return FALSE;
if (d->rela.hdr
&& !_bfd_elf_set_reloc_sh_name (abfd,
d->rela.hdr,
name, FALSE))
return FALSE;
if (debug_shdrpp == NULL)
debug_shdrpp = shdrpp;
/* Update section size and contents. */
shdrp->sh_size = shdrp->bfd_section->size;
shdrp->contents = shdrp->bfd_section->contents;
shdrp->sh_size = sec->size;
shdrp->contents = sec->contents;
shdrp->bfd_section->contents = NULL;
}
off = _bfd_elf_assign_file_position_for_section (shdrp,
off,
TRUE);
else
off = _bfd_elf_assign_file_position_for_section (shdrp,
off,
TRUE);
}
}
}
/* Place the section headers. */
/* Place section name section after DWARF debug sections have been
compressed. */
_bfd_elf_strtab_finalize (elf_shstrtab (abfd));
shdrp = &elf_tdata (abfd)->shstrtab_hdr;
shdrp->sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd));
off = _bfd_elf_assign_file_position_for_section (shdrp, off, TRUE);
/* Place DWARF debug sections after section name section. */
if (debug_shdrpp)
for (shdrpp = debug_shdrpp; shdrpp < end_shdrpp; shdrpp++)
{
shdrp = *shdrpp;
if (shdrp->sh_offset == -1)
off = _bfd_elf_assign_file_position_for_section (shdrp, off, TRUE);
}
/* Place the section headers. */
i_ehdrp = elf_elfheader (abfd);
bed = get_elf_backend_data (abfd);
off = align_file_position (off, 1 << bed->s->log_file_align);
@@ -5632,6 +5747,9 @@ _bfd_elf_write_object_contents (bfd *abfd)
num_sec = elf_numsections (abfd);
for (count = 1; count < num_sec; count++)
{
i_shdrp[count]->sh_name
= _bfd_elf_strtab_offset (elf_shstrtab (abfd),
i_shdrp[count]->sh_name);
if (bed->elf_backend_section_processing)
(*bed->elf_backend_section_processing) (abfd, i_shdrp[count]);
if (i_shdrp[count]->contents)

View File

@@ -345,6 +345,10 @@ CODE_FRAGMENT
. TMS320C54X only. *}
.#define SEC_TIC54X_BLOCK 0x10000000
.
. {* This section should be renamed. This is for ELF linker
. internal use only. *}
.#define SEC_ELF_RENAME 0x10000000
.
. {* Conditionally link this section; do not link if there are no
. references found to any symbol in the section. This is for TI
. TMS320C54X only. *}

View File

@@ -2929,6 +2929,9 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
/* Copy merge entity size. */
osection->entsize = isection->entsize;
/* Copy compress status. */
osection->compress_status = isection->compress_status;
/* This used to be mangle_section; we do here to avoid using
bfd_get_section_by_name since some formats allow multiple
sections with the same name. */

View File

@@ -566,7 +566,7 @@ if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
fail "$testname"
send_log "$got\n"
}
if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3.W] } then {
if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3gabi.W] } then {
fail "$testname"
} else {
pass "$testname"

View File

@@ -1,7 +1,7 @@
.*dw2-1-compressed.o: file format .*
Contents of the .debug_info section:
Contents of the .z?debug_info section:
Compilation Unit @ offset 0x0:
Length: 0x4e \(32-bit\)
@@ -30,7 +30,7 @@ Contents of the .debug_info section:
<50> DW_AT_encoding : 5 \(signed\)
<1><51>: Abbrev Number: 0
Raw dump of debug contents of section .debug_line:
Raw dump of debug contents of section .z?debug_line:
Offset: 0x0
Length: 62

View File

@@ -1,7 +1,7 @@
.*: +file format .*
Contents of the .debug_info section:
Contents of the .zdebug_info section:
Compilation Unit @ offset 0x0:
Length: 0x5e \(32-bit\)
@@ -56,7 +56,7 @@ Contents of the .debug_info section:
<9b> DW_AT_const_value : 2
<1><9c>: Abbrev Number: 0
Contents of the .debug_abbrev section:
Contents of the .zdebug_abbrev section:
Number TAG \(0x0\)
1 DW_TAG_compile_unit \[has children\]
@@ -110,7 +110,7 @@ Contents of the .debug_abbrev section:
DW_AT_const_value DW_FORM_data1
DW_AT value: 0 DW_FORM value: 0
Raw dump of debug contents of section .debug_line:
Raw dump of debug contents of section .z?debug_line:
Offset: 0x0
Length: 62

View File

@@ -0,0 +1,156 @@
.*: +file format .*
Contents of the .debug_info section:
Compilation Unit @ offset 0x0:
Length: 0x5e \(32-bit\)
Version: 2
Abbrev Offset: 0x0
Pointer Size: 4
<0><b>: Abbrev Number: 1 \(DW_TAG_compile_unit\)
<c> DW_AT_stmt_list : 0x0
<10> DW_AT_high_pc : 0x4
<14> DW_AT_low_pc : 0x0
<18> DW_AT_name : file1.txt
<22> DW_AT_producer : GNU C 3.3.3
<2e> DW_AT_language : 1 \(ANSI C\)
<1><2f>: Abbrev Number: 2 \(DW_TAG_subprogram\)
<30> DW_AT_external : 1
<31> DW_AT_decl_file : 1
<32> DW_AT_decl_line : 2
<33> DW_AT_name : func_cu1
<3c> DW_AT_type : <0x85>
<40> DW_AT_low_pc : 0x0
<44> DW_AT_high_pc : 0x4
<48> DW_AT_frame_base : 1 byte block: 55 \(DW_OP_reg5 \([^()]*\)\)
<1><4a>: Abbrev Number: 3 \(DW_TAG_base_type\)
<4b> DW_AT_name : int1
<50> DW_AT_byte_size : 4
<51> DW_AT_encoding : 5 \(signed\)
<1><52>: Abbrev Number: 4 \(DW_TAG_const_type\)
<53> DW_AT_type : <0x4a>
<1><57>: Abbrev Number: 5 \(DW_TAG_variable\)
<58> DW_AT_name : one
<5c> DW_AT_type : <0x52>
<60> DW_AT_const_value : 1
<1><61>: Abbrev Number: 0
Compilation Unit @ offset 0x62:
Length: 0x37 \(32-bit\)
Version: 2
Abbrev Offset: 0x45
Pointer Size: 4
<0><6d>: Abbrev Number: 1 \(DW_TAG_compile_unit\)
<6e> DW_AT_name : file1.txt
<78> DW_AT_producer : GNU C 3.3.3
<84> DW_AT_language : 1 \(ANSI C\)
<1><85>: Abbrev Number: 2 \(DW_TAG_base_type\)
<86> DW_AT_name : int2
<8b> DW_AT_byte_size : 4
<8c> DW_AT_encoding : 5 \(signed\)
<1><8d>: Abbrev Number: 3 \(DW_TAG_const_type\)
<8e> DW_AT_type : <0x85>
<1><92>: Abbrev Number: 4 \(DW_TAG_variable\)
<93> DW_AT_name : two
<97> DW_AT_type : <0x8d>
<9b> DW_AT_const_value : 2
<1><9c>: Abbrev Number: 0
Contents of the .debug_abbrev section:
Number TAG \(0x0\)
1 DW_TAG_compile_unit \[has children\]
DW_AT_stmt_list DW_FORM_data4
DW_AT_high_pc DW_FORM_addr
DW_AT_low_pc DW_FORM_addr
DW_AT_name DW_FORM_string
DW_AT_producer DW_FORM_string
DW_AT_language DW_FORM_data1
DW_AT value: 0 DW_FORM value: 0
2 DW_TAG_subprogram \[no children\]
DW_AT_external DW_FORM_flag
DW_AT_decl_file DW_FORM_data1
DW_AT_decl_line DW_FORM_data1
DW_AT_name DW_FORM_string
DW_AT_type DW_FORM_ref_addr
DW_AT_low_pc DW_FORM_addr
DW_AT_high_pc DW_FORM_addr
DW_AT_frame_base DW_FORM_block1
DW_AT value: 0 DW_FORM value: 0
3 DW_TAG_base_type \[no children\]
DW_AT_name DW_FORM_string
DW_AT_byte_size DW_FORM_data1
DW_AT_encoding DW_FORM_data1
DW_AT value: 0 DW_FORM value: 0
4 DW_TAG_const_type \[no children\]
DW_AT_type DW_FORM_ref4
DW_AT value: 0 DW_FORM value: 0
5 DW_TAG_variable \[no children\]
DW_AT_name DW_FORM_string
DW_AT_type DW_FORM_ref4
DW_AT_const_value DW_FORM_data1
DW_AT value: 0 DW_FORM value: 0
Number TAG \(0x45\)
1 DW_TAG_compile_unit \[has children\]
DW_AT_name DW_FORM_string
DW_AT_producer DW_FORM_string
DW_AT_language DW_FORM_data1
DW_AT value: 0 DW_FORM value: 0
2 DW_TAG_base_type \[no children\]
DW_AT_name DW_FORM_string
DW_AT_byte_size DW_FORM_data1
DW_AT_encoding DW_FORM_data1
DW_AT value: 0 DW_FORM value: 0
3 DW_TAG_const_type \[no children\]
DW_AT_type DW_FORM_ref4
DW_AT value: 0 DW_FORM value: 0
4 DW_TAG_variable \[no children\]
DW_AT_name DW_FORM_string
DW_AT_type DW_FORM_ref4
DW_AT_const_value DW_FORM_data1
DW_AT value: 0 DW_FORM value: 0
Raw dump of debug contents of section .debug_line:
Offset: 0x0
Length: 62
DWARF Version: 2
Prologue Length: 35
Minimum Instruction Length: 1
Initial value of 'is_stmt': 1
Line Base: 1
Line Range: 1
Opcode Base: 16
Opcodes:
Opcode 1 has 0 args
Opcode 2 has 1 args
Opcode 3 has 1 args
Opcode 4 has 1 args
Opcode 5 has 1 args
Opcode 6 has 0 args
Opcode 7 has 0 args
Opcode 8 has 0 args
Opcode 9 has 1 args
Opcode 10 has 0 args
Opcode 11 has 0 args
Opcode 12 has 1 args
Opcode 13 has 0 args
Opcode 14 has 0 args
Opcode 15 has 0 args
The Directory Table is empty.
The File Name Table \(offset 0x1f\):
Entry Dir Time Size Name
1 0 0 0 file1.txt
Line Number Statements:
\[0x0000002d\] Extended opcode 2: set Address to 0x0
\[0x00000034\] Advance Line by 3 to 4
\[0x00000036\] Copy
\[0x00000037\] Copy
\[0x00000038\] Extended opcode 2: set Address to 0x4
\[0x0000003f\] Extended opcode 1: End of Sequence

View File

@@ -1,7 +1,7 @@
.*dw2-compressed.o: file format .*
Contents of the .debug_info section:
Contents of the .z?debug_info section:
Compilation Unit @ offset 0x0:
Length: 0x4e \(32-bit\)
@@ -30,7 +30,7 @@ Contents of the .debug_info section:
<50> DW_AT_encoding : 5 \(signed\)
<1><51>: Abbrev Number: 0
Raw dump of debug contents of section .debug_line:
Raw dump of debug contents of section .z?debug_line:
Offset: 0x0
Length: 62
@@ -74,7 +74,7 @@ Raw dump of debug contents of section .debug_line:
\[0x.*\] Extended opcode 1: End of Sequence
Contents of the .debug_abbrev section:
Contents of the .zdebug_abbrev section:
Number TAG \(0x0\)
1 DW_TAG_compile_unit \[has children\]

View File

@@ -142,6 +142,9 @@ ldfile_try_open_bfd (const char *attempt,
/* Linker needs to decompress sections. */
entry->the_bfd->flags |= BFD_DECOMPRESS;
/* This is the linker output BFD. */
entry->the_bfd->is_linker_input = 1;
#ifdef ENABLE_PLUGINS
if (entry->flags.lto_output)
entry->the_bfd->lto_output = 1;

View File

@@ -0,0 +1,9 @@
#source: compress1.s
#as: --compress-debug-sections=none
#ld: -r --compress-debug-sections=zlib-gnu
#readelf: -SW
#failif
#...
\[[ 0-9]+\] \.zdebug_aranges[ ]+(PROGBITS|MIPS_DWARF)[ 0-9a-z]+ .*
#...

View File

@@ -0,0 +1,9 @@
#source: compress1.s
#as: --compress-debug-sections=none
#ld: -shared --compress-debug-sections=zlib-gnu
#readelf: -SW
#failif
#...
\[[ 0-9]+\] \.zdebug_aranges[ ]+(PROGBITS|MIPS_DWARF)[ 0-9a-z]+ .*
#...