https://sourceware.org/bugzilla/show_bug.cgi?id=31929

--- Comment #2 from Ralf Habacker <ralf.habacker at freenet dot de> ---
(In reply to Ralf Habacker from comment #1)
> It doesn't seem to be so easy to find the appropriate place. Is there a way
> to output the file and line where bfd_set_error() is called ?

It looks like there is no such option for end users. The only supported option
seems to be using a debugger and setting a breakpoint in the hope that you
don't reach the appropriate one at some point. 

In the specific case this is: 

#0 bfd_set_error (error_tag=error_tag@entry=bfd_error_bad_value) at
../../bfd/bfd.c:800
#1 0x0000555555555c942a in bfd_set_section_contents
(abfd=abfd@entry=0x555555557233b0, section=0x555555557253a8,
location=<optimized out>, offset=<optimized out>, count=<optimized out>)
    at ../../bfd/section.c:1509
#2 0x00005555555de5f0 in _bfd_coff_link_input_bfd
(flaginfo=flaginfo@entry=0x7fffffffe090,
input_bfd=input_bfd@entry=0x55555b626720) at ../../bfd/cofflink.c:2509
#3 0x0000555555555df937 in _bfd_coff_final_link (abfd=<optimized out>,
info=0x55555555700de0 <link_info>) at ../../bfd/cofflink.c:898
#4 0x00005555555559af8e in ldwrite () at ../../ld/ldwrite.c:550
#5 0x0000555555582bfe in main (argc=<optimized out>, argv=<optimized out>) at
../../ld/ldmain.c:528

The generated file has the following size at this point

  -rw-r--r-- 1 abuild abuild 3087021376 Jun 26 14:22 Qt5WebKit.dll

and the error is triggered in the following function: 

1490 bfd_set_section_contents (bfd *abfd,
1491 sec_ptr section,
1492 const void *location,
1493 file_ptr offset,1494 bfd_size_type count)1495 {1496 bfd_size_type
sz;14971498 if (!(bfd_section_flags (section) & SEC_HAS_CONTENTS))1499 {
1500 bfd_set_error (bfd_error_no_contents);
1501 return false;
1502 }
1503
1504 sz = section->size;
1505 if ((bfd_size_type) offset > sz
1506 count > sz - offset
1507 count != (size_t) count)
1508 {
1509 bfd_set_error (bfd_error_bad_value);
1510 return false;
1511 }

After inspecting the individual values: 

(gdb) p o->output_offset
$17 = 2762844077
(gdb) p loc
$18 = <optimized out>
(gdb) p o->size
$19 = 4898386

and interpretation is obtained: 

offset 2762844077  
sz 2764867072 section_size  
count 4898386  
sz-offset 2022995

The checked conditions 

1505: Offset > sz   -->  no    
1506: Count > sz - offset   -> yes

show that the comparison in line 1506 leads to the error.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to