This is the mail archive of the dwarf2@corp.sgi.com mailing list for the dwarf2 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Appendix 5 problem?


Ron Brender writes:
>Keith Walker reported the attached problem to me. I think he is right,
>but I would like someone else to double check and confirm.
>
>The needed changes are (Appendix 5):
>
>  - In "The table for foo subroutine", change
>
>	from		to		occurrences
>
>	c12		c-12		2
>	c8		c-8		5
>	c4		c-4		7
>
>  - In the CIE, at address cie+11, change the data alignment value
>    from 4 to -4.

I think Keith Walker is right, if the stack grows to lower addresses,
and the words 'The stack grows in the negative direction.' support this, 
I think.

Ron: Note that in recreating appendix 5, you left off a <fs>
operand at foo+76 (to the add instruction).

The example suffers from another, related, defect.

Consider <fsize>

The table for foo+8 says cfa is [r7]+fsize
implying fsize is positive (as the stack grows down to lower addresses).
And we know that, now that the data alignment is -4.
And we use <fsize-n> as the store offset in the instructions.

But if so,  then the fde+17 line is wrong as it says
fde+17  DW_CFA_def_cfa_offset(<fsize>/4) but that should
be -4 as the constant, and if  fsize is positive, oops. 

If fsize is negative, and  <fsize>/-4 makes sense,
and the fde table makes sense.  And the  Loc/CFA table makes sense.
But then none of the instructions in the instruction
set make sense, as there <fs> must be positive.

(Presuming <fs> and <fsize> are the same value.)

I think it's more sensible to say that fsize is positive and
so therefore 
        fde+17  DW_CFA_def_cfa_offset(<fsize>/4) 
should really be
	fde+17  DW_CFA_def_cfa_offset(-<fsize>/-4)
and then I think everything works out with fsize and fs, with
the other changes , using -4 as data alignment, and using
c-12, c-4 etc, as clearly the table printed is intended to
be after the data alignment is factored back in..

The other DW_CFA_offset
are really
	DW_CFA_offset(regno, cfa_off/-4)
where cfa_off is -4,or -8 or -12, as appropriate, and
the divisor is the data_alignment factor.
I think this would be easier to read as
	fde+23 DW_CFA_offset(6, -8/-4)
Perhaps. And so on. Rather than just '2'.


It would be nice to have each table in the appendix have an
id of some sort, making it easier to refer to each
table there.  CIE and FDE tables do have a title,
but the table before it (the foo subroutine table?) does not.


Hoping the above has some semblance of correctness, I sign off...
davea@sgi.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]