• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
fir

static symbols and linker

10 posts in this topic

If i do write in c source and compile this to .o 

 

int x=1;

 

static int y=2;

 

static int f() 

{

  return 100;

}

 

int g()

{

  return 200;

}

 

the symbols of y and f are internal - I know obj .o file has a some

table of exported symbols and offsets to binary inside, would just 

the symbols y and f  be deleted or maybe only marked as internal ?

(maybe someone would know if ofset to binary is also deleted there)

tnx for answer 

 

(is the .o format (used by 32 bit mingw/gcc) hard to learn ? maybe 

someone know some easy tutorial on this?)

1

Share this post


Link to post
Share on other sites

for me understanding coff would be usefull - also understanding what exactly linkers do (i heard they are very small programs doing very simple things but i dont know exactly what they do)

0

Share this post


Link to post
Share on other sites

Object files with unresolved references include information about the name of each unresolved reference and the places in the executable code where they need to be fixed up. The object code has dummy values which the linker fills in with the correct address when it knows the address of all the symbols.

 

It's more complicated if the object code can be relocated to an arbitrary address (basically, the "linked" code still needs the fixup table then) but you get the idea.

Edited by Paradigm Shifter
1

Share this post


Link to post
Share on other sites

Object files with unresolved references include information about the name of each unresolved reference and the places in the executable code where they need to be fixed up. The object code has dummy values which the linker fills in with the correct address when it knows the address of all the symbols.

 

It's more complicated if the object code can be relocated to an arbitrary address (basically, the "linked" code still needs the fixup table then) but you get the idea.

 

could you maybe say what is fixed exactly, how it looks like? lets say 

there is external symbol f and corresponding function body in binary

0

Share this post


Link to post
Share on other sites

call unresolved symbol f

 

in the object code it is stored as:

call ????

 

where ???? could be anything.

 

f is in the unresolved symbol table. There is an entry for the location of ???? in the machine code data which needs fixing up.

Linker knows about all the function addresses from every module (otherwise it is a link error - unresolved external symbol). It replaces ???? with the actual address of f in the binary when linked.

2

Share this post


Link to post
Share on other sites

call unresolved symbol f

 

in the object code it is stored as:

call ????

 

where ???? could be anything.

 

f is in the unresolved symbol table. There is an entry for the location of ???? in the machine code data which needs fixing up.

Linker knows about all the function addresses from every module (otherwise it is a link error - unresolved external symbol). It replaces ???? with the actual address of f in the binary when linked.

 

ah, i see - you mean when i got some module and use external symbols here (for example printfs or winapi calls) - linker fills this

calls with proper adresses, and thats all? very little work

1

Share this post


Link to post
Share on other sites
Yes, that is their main job. The linker gets a list of functions that are missing, looks up their final address, and fills in the holes. Then it stuffs everything together into one file, and calls the result an EXE.


Linkers can do more things than their main job. They can perform optimizations at a whole-program level. They are responsible for coordinating debug information, either consolidating it for use or discarding it. They can strip out functions that nobody uses. They can apply digital signatures. Those are just bonus features.
1

Share this post


Link to post
Share on other sites

Yes, that is their main job. The linker gets a list of functions that are missing, looks up their final address, and fills in the holes. Then it stuffs everything together into one file, and calls the result an EXE.


Linkers can do more things than their main job. They can perform optimizations at a whole-program level. They are responsible for coordinating debug information, either consolidating it for use or discarding it. They can strip out functions that nobody uses. They can apply digital signatures. Those are just bonus features.

 

and what with inner module calls and jumps, and also static in-module data adresses - are the in module calls and jumps made by relative jumps or by 'static' adres calls if they done by static adresses and in both modules they begin adressing from 0 (in some 0-based adress space) when linking two modules we got conflict of adress spaces,

what with that (i heard vaguelly (but im not sure) that linker need to realloc all such kind of in-module adressing, it would be probably all non-relative jumps/calls and all not relative adressing - and this would be many of them - maybe this set of references to re-fix is the same set as set of internal symbols - because usualy when you got a call this is a symbol of function name and when you got static adressing this is a

symbol for static data too), but im not sure how this works [when i was reading something about it i do not quite understood it] could someone a bit elaborate on this?

0

Share this post


Link to post
Share on other sites
That is where the "internal linkage", "external linkage", and "no linkage" stuff in the language standard becomes important.


Things with "no linkage" or "internal linkage" are not left as blanks in the object file. The compiler might leave the symbol information in there so the debugger knows where they are, but they are not blanks to be replaced. Only functions with "external linkage" are used for replacement, and there can only be one of those. If there are multiple, or if they are missing, it becomes an error at link time.

If you study the coff and pe formats, you will notice that each module can be relocated at runtime. So yes, each module has addresses relative to its own address space, but they get relocated naturally so that part is taken care of.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0