1. A method comprising: for each object file among a plurality of object files comprising a plurality of objects, categorizing the objects in the object file as static objects defined as having a static storage duration or undefined objects not defined as having a static storage duration, wherein the static storage duration indicates that the static objects are initialized when an executable module comprising the static objects is loaded, and wherein the object files are generated by a compiler from source code in a plurality of source files corresponding to the object files; creating a directed graph of the object files, wherein the directed graph comprises a plurality of nodes that each represent one of the object files, wherein the directed graph comprises a plurality of edges between pairs of the nodes, wherein each edge among the edges has a direction from a first node among the nodes to a second node among the nodes, wherein the first node represents a first object file among the object files and the second node represents a second object file among the object files, and wherein the edge indicates that the first object file comprises one of the undefined objects that has a same identifier as one of the static objects in the second object file; applying, by at least one processor device, topological sorting to the directed graph to determine an order of the object files that ensures a correct initialization of the static objects by placing, for each of the edges, the second node before the first node in the order; and passing a list of the object files in the order to a linker that links the object files to build the executable module.