Download the "master" records after primary upload and perform some mapping related to (Name -> Id). In Excel, this could be accomplished with VLOOKUP. Once you have formed a new list of "detail" objects, there should be no difficulty uploading them. The mapping "ID->uploaded records" is also accessible in the success log file created by Apex Data Loader.
But the better way is to say loudly "screw the Salesforce ID, I don't need no stinking ID" :) Think if your "master" has some unique field. It can even be the "ID" from your existing system from which you import to Salesforce. Create this field in Salesforce (if you didn't do it already) and mark it as "External ID". Afterwards, you will be able to use this external ID instead of normal Salesforce ID as a way to make the link between source and target. In pseudocode:
with normal Salesforce ID, you must
INSERT INTO detail_object (Name, SomeValue, master_ID) VALUES ("foo", "bar", [some valid salesforce id])
With external IDs, you can have it easy and tell salesforce to do all the heavy lifting
INSERT INTO detail_object (Name, SomeValue, master_ID) VALUES ("foo", "bar", (SELECT Id from master_object where some_field_marked_as_external_id = "123")
Check out the Data Loader user guide for quick start and play with external ids if you can (in the free developer edition maybe?). It's easier to use than to describe it.