To avoid some linking errors
Daniel Murphy
yebblies at nospamgmail.com
Mon Oct 29 23:08:24 PDT 2012
"Walter Bright" <newshound2 at digitalmars.com> wrote in message
news:k6npgi$1hsr$1 at digitalmars.com...
> On 10/29/2012 9:51 PM, Daniel Murphy wrote:> "Walter Bright"
> <newshound2 at digitalmars.com> wrote in message
> > news:k6mun3$a8h$1 at digitalmars.com...
> >>
> >> The object file format does not support line numbers for symbol
> >> references
> >> and definitions. None of the 4 supported ones (OMF, ELF, Mach-O,
> >> MsCoff)
> >> have that. Even the symbolic debug info doesn't have line numbers for
> >> references, just for definitions.
> >
> > While this is true, you could scan the relocations for matching symbols,
> > then use the debug information to get line numbers. This would work for
> > all
> > function calls at least.
>
>
> If the symbol is undefined, then there is no debug info for it.
There will be debug information for the call site if it is in the user's
program.
eg
void foo();
void main()
{
foo();
}
>dmd testx -g
DMD v2.061 DEBUG
OPTLINK (R) for Win32 Release 8.00.12
Copyright (C) Digital Mars 1989-2010 All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
testx.obj(testx)
Error 42: Symbol Undefined _D5testx3fooFZv
--- errorlevel 1
>objconv -dr testx.obj
Dump of file: testx.obj, type: OMF32
Checksums are zero
LEDATA, LIDATA, COMDAT and FIXUPP records:
LEDATA: segment $$SYMBOLS, Offset 0x0, Size 0x4B
FIXUPP:
Direct farword 32+16 bit, Offset 0x30, group FLAT. Symbol __Dmain (T6),
inlin
e 0x0:0x0
COMDAT: name , Offset 0x0, Size 0xD, Attrib 0x00, Align 0, Type 0, Base 0
FIXUPP:
Relatv 32 bit, Offset 0x4, group FLAT. Symbol _D5testx3fooFZv (T6),
inline 0x
1000E
LEDATA: segment _DATA, Offset 0x0, Size 0xE
LEDATA: segment FM, Offset 0x0, Size 0x4
FIXUPP:
Direct 32 bit, Offset 0x0, group FLAT. Segment _DATA (T4), inline 0x0
LEDATA: segment $$TYPES, Offset 0x0, Size 0x16
The FIXUPP record gives Offset 0x4 for the address _D5testx3fooFZv, and the
debug information for main will give the line number of that offset.
I wouldn't want to implement it in assembly though.
More information about the Digitalmars-d
mailing list