From: brutus <mad...@gm...> - 2003-10-16 18:46:10
|
Frank Kotler wrote: > Hi, Brutus! > > Thanks for joining us. I'm *way* over my head on this stuff, but > debugging code by clueless trial-and-error is something I'm gaining > experience at :) > >> brutus wrote: >> while debuging, OllyDbg[1] remarks that my entry point is outside the >> codesegment and complains about beeing outside the code segment when i >> set breakpoints. > > > Adding "class=code" to the segment declaration seems to fix this. I > added "flat", too. Dunno what it does, but it sounds cool :) I think > it's the "class=code" that fixed it. hmm, great! works for me too. as far as i understand it, the flat thing just makes sense in Os/2 programms (see below). if i used it, my code seg just becomes part of a group called flat. you can verify this if you look at the map files of your linker (use -m with alink to get it). the class=code options works, but i don't understand why. any hints someone? it *seems* to have nothing to do with the correct assembling/linking and don't *seem* to influence the prog. i think it's an OlyyDbg thing, maybe with the way OllyDbg decides if some segment is a code segment? if you uncheck DebugOptions/Security/"Warn when breakpoint is outside the code section" the warning won't get displayed anymore. here are some snippets i found in the nasm docs, that could clarify a bit: The Unix object formats, and the bin object format (but see section 6.1.3, all support the standardised section names .text, .data and .bss for the code, data and uninitialised-data sections. The obj format, by contrast, does not recognise these section names as being special, and indeed will strip off the leading period of any section name that has one. The obj format does not define any special segment names: you can call your segments anything you like. Typical names for segments in obj format files are CODE, DATA and BSS. The obj output format extends the SEGMENT (or SECTION) directive to allow you to specify various properties of the segment you are defining. This is done by appending extra qualifiers to the end of the segment-definition line. The available qualifiers are: * PRIVATE, PUBLIC, COMMON and STACK specify the combination characteristics of the segment. _PRIVATE_ segments do not get combined with any others by the linker; _PUBLIC_ and _STACK_ segments get concatenated together at link time; and _COMMON_ segments all get overlaid on top of each other rather than stuck end-to-end. * ALIGN _ALIGN_ is used, as shown above, to specify how many low bits of the segment start address must be forced to zero. The alignment value given may be any power of two from 1 to 4096; in reality, the only values supported are 1, 2, 4, 16, 256 and 4096, so if 8 is specified it will be rounded up to 16, and 32, 64 and 128 will all be rounded up to 256, and so on. Note that alignment to 4096-byte boundaries is a PharLap extension to the format and may not be supported by all linkers. * CLASS _CLASS_ can be used to specify the segment class; this feature indicates to the linker that segments of the same class should be placed near each other in the output file. The class name can be any word, e.g. CLASS=CODE. * OVERLAY _OVERLAY_, like _CLASS_, is specified with an arbitrary word as an argument, and provides overlay information to an overlay-capable linker. * USE Segments can be declared as _USE16_ or _USE32_, which has the effect of recording the choice in the object file and also ensuring that NASM's default assembly mode when assembling in that segment is 16-bit or 32-bit respectively. * FLAT When writing OS/2 object files, you should declare 32-bit segments as _FLAT_, which causes the default segment base for anything in the segment to be the special group _FLAT_, and also defines the group if it is not already defined. * ABSOLUTE The obj file format also allows segments to be declared as having a pre-defined absolute segment address, although no linkers are currently known to make sensible use of this feature; nevertheless, NASM allows you to declare a segment such as SEGMENT SCREEN ABSOLUTE=0xB800 if you need to. The _ABSOLUTE_ and _ALIGN_ keywords are mutually exclusive. NASM's default segment attributes are PUBLIC, ALIGN=1, no class, no overlay, and USE16. |