Commit Graph

146 Commits

Author SHA1 Message Date
Bill Currie 39c1034afb Relocate the data in the type encodings space.
Because of the way it is used, the data in the type encodings space needs
to always be correct (ie, relocated), even for partially linked object
files.
2012-11-14 20:37:19 +09:00
Bill Currie 3b3e013d4a Do not demand a defined def is actually global.
Rather, only that it is neither external nor local. The idea was to catch
myself swapping the arguments to resolve_external_def, but for some reason
I decided type encoding defs would not be global (save game reasons?).
2012-11-14 15:50:55 +09:00
Bill Currie acc188d62b Ressurect the builtin symbol type fixup.
I was a little overzealous when gutting process_type_space :P
2012-11-14 15:49:19 +09:00
Bill Currie 33eb3f2418 A bit of pointer saftey in add_defs.
Directly accessing odef after can be dangerous (probably not here, but
hey), so use the defref instead.
2012-11-14 13:25:30 +09:00
Bill Currie 00c87434bf A touch of whitespace. 2012-11-14 13:25:03 +09:00
Bill Currie 281e203545 Make process_data_def use the correct def tables.
Fixes the bogus redefined errors when entity fields are used.

Also, rename extern_defs and defined_defs to extern_data_defs and
defined_data_defs (more consistent with the other tables).
2012-11-14 13:14:54 +09:00
Bill Currie e05c12e16d Make linker_add_def take a pointer for the value.
While it looks like I might not use it for the type encodings, it should be
useful in the future.
2012-11-14 13:12:58 +09:00
Bill Currie 51236b0693 Fix the incorrect type space reloc offsets.
The problem was caused by add_relocs and process_loose_relocs adjusting the
reloc offset based on the reloc's space's base address. This is fine for
most relocs, but as relocs for the type space have already been adjusted by
process_type_space, those relocs must be left alone by add_relocs and
process_loose_relocs. As a bonus, the duplicate code has been refactored
into a separate function :)
2012-11-14 10:29:45 +09:00
Bill Currie 31739f4dbf Rewrite the type_space processing.
Now each encoding is copied across def by def using memcpy, with the
expectation that any references to other types will be handled via the
reloc system. Unfortunately, it seems there's an off-by-4 (hmm, suspicious
number...) in the reloc offsets, but I'll look into that after I get some
sleep.
2012-11-13 21:55:54 +09:00
Bill Currie 8625964634 Fix some careless inernal_error changes.
Back when I did the abort->internal_error change, I wasn't paying attention
and forgot I should use linker_internal_error in linker.c.
2012-11-13 21:51:16 +09:00
Bill Currie f80a74228c Add (and use) alloc_data for work qfo data allocations.
defspace_alloc_loc can cause a realloc which will break the work qfo space
data pointers, so wrap it with alloc_data, which updates the appropriate
pointers and sizes.
2012-11-13 21:48:46 +09:00
Bill Currie 1dd8f34190 Refactor process_def.
The field/data def handling has been moved into process_data_def and
process_field def. The code for handling external defs has been moved into
its own function (extern_def()),

In passing, rename add_space to add_data_space, since it is limited to
handling data spaces.
2012-11-13 13:16:45 +09:00
Bill Currie ba6fb5802d Make add_defs take a function to process the defs.
For now, no other change has been made, but I'll be able to split up
process_def for data def vs field def processing and add a function for
processing type encoding defs.
2012-11-13 12:40:40 +09:00
Bill Currie c96718493a A bit of a cleanup before fixing class type defs.
All internal structs now have "proper" names, and fit the naming convention
(eg, obj_module (like objective-c's types, but obj instead of objc). Some
redundant types got removed (holdovers from before proper struct tag
handling).

Also, it has proven to be unnecessary to build internal classes, so
make_class and make_class_struct are gone, too.
2012-11-12 11:12:33 +09:00
Bill Currie 6ec5bb1884 Change the FIXME to a comment as to why nothing is done.
Of course, the relocation record still needs to be written (don't know why
it isn't), but that's next :)
2012-11-11 20:36:25 +09:00
Bill Currie 8710977323 Rework transfer_type to avoid infinite recursion.
This is similar to the problem with infinite recursion when encoding types.
The problem is with structs with self-referential pointers (eg, struct foo
{struct foo *bar}). The solution is to copy the type data to a buffer and
mark the buffer as transfered before actually processing the type. Further
processing of the type is done via the buffer.
2012-11-11 20:20:07 +09:00
Bill Currie afbab60c25 Create linker_find_def.
It turns out I didn't need it, but it could be useful in the future, so
I'll leave it in.
2012-11-09 11:57:06 +09:00
Bill Currie 377f8f9d56 Use an explicit flag for class initialization.
Much cleaner than messing with class_Class, which is about to go away.
2012-11-08 17:14:33 +09:00
Bill Currie ec42bde527 Make hash tables more const correct.
And clean up the resulting mess :/
2012-10-27 11:44:31 +09:00
Bill Currie 27b83a8d65 Clean up all extra aborts, using internal_error instead.
Some internal_error calls have no message, but at least things will be more
consistent.
2012-10-26 19:02:02 +09:00
Bill Currie 23a38738fc Massive whitespace cleanup.
Lots of trailing whitespace and otherwise blank lines.
2012-05-22 08:23:22 +09:00
Bill Currie bc1b483525 Nuke the rcsid stuff.
It's pretty useless in git.
2012-04-22 10:56:32 +09:00
Bill Currie d910c14935 Clean up some doxygen warnings. 2011-07-10 19:12:07 +09:00
Bill Currie 0f7390dd60 Clean up all the "set but not used" warnings.
gcc on my system is failing to treat this specific warning as an error :/
2011-06-19 10:48:02 +09:00
Bill Currie b522853765 Ensure the target of def_op relocs gets updated.
These occur only when switch statements use jump tables, thus why the
problem went unnoticed :/
2011-04-08 17:09:40 +09:00
Bill Currie 92ba110a87 Ensure a field def is emitted for @this. 2011-04-03 13:03:48 +09:00
Bill Currie 7f67e6eb17 Refactor the def handling code a little. 2011-04-03 13:03:22 +09:00
Bill Currie 6d0b13dbf0 Resolve types whenever possible. 2011-04-03 13:02:04 +09:00
Bill Currie 9b62c8c126 Rename ty_type_e to ty_meta_e and type_t.ty to type_t.meta 2011-03-22 16:06:47 +09:00
Bill Currie f1d9570dc8 Fix constant value type handling.
Rename immediate.[ch] to value.[ch] and clean up the mess.

Add convert_value() to convert the type of a value (only scalar types).
2011-03-22 12:24:39 +09:00
Bill Currie 505bde308e Fix the handling of @system defs.
When treating a def as external, actually say it is external.
2011-03-07 20:53:27 +09:00
Bill Currie 8dbf8a97ea Be more informative with ext/def internal errors. 2011-03-07 20:52:31 +09:00
Bill Currie 49e446b637 Make field defs global.
It turns out that field defs need to be global after all, so use separate
field def tables in the linker.
2011-03-07 14:45:50 +09:00
Bill Currie c4e9a45d91 Do not lose the entity field defs. 2011-03-06 15:40:07 +09:00
Bill Currie 97b1ceceb0 Fix line number info.
line number info is now 1 based rather than 0 based (to better detect when
a function does not have line number info).
2011-03-05 15:40:08 +09:00
Bill Currie 7c95913c61 Avoid segfaulting with bad string relocs. 2011-03-05 09:07:16 +09:00
Bill Currie fe7be543f8 Correctly update the offset of code relocs. 2011-03-05 08:39:47 +09:00
Bill Currie c3f1c186f8 Resolve types of .return etc. 2011-03-05 08:36:55 +09:00
Bill Currie e62163e569 Nuke any invalidated relocs. 2011-03-04 21:46:19 +09:00
Bill Currie 2565e0db32 Update reloc targets when linking. 2011-03-04 21:29:47 +09:00
Bill Currie e04f6266b1 Nuke def_list from defref_t.
It didn't work :/.
2011-03-04 20:40:01 +09:00
Bill Currie 2211a807d4 Do not relocate builtin functions. 2011-03-04 18:46:25 +09:00
Bill Currie 9a96febdf5 Fix the hordes of bogus defs.
They were caused by unused external defs, so not processing unused externs
in the first place is the simplest solution.
2011-03-04 14:51:09 +09:00
Bill Currie 7b7f4c70e0 Correct non-external def processing. 2011-03-04 14:33:03 +09:00
Bill Currie c5dac6d1d1 Transfer the type encoding.
oops
2011-03-04 14:29:22 +09:00
Bill Currie e525727a24 Add a null type descriptor to the linker output. 2011-03-04 11:38:33 +09:00
Bill Currie 3a828ca5c2 Ensure work spaces are always connected to their data. 2011-03-04 11:18:56 +09:00
Bill Currie 29985efcef Expose some linker functions to the rest of the compiler.
They proved to be useful for cleaning up the final compilation stages.
2011-03-02 20:48:55 +09:00
Bill Currie 065d3e0dd7 Partial linking for a single qfo file now seems to work. 2011-03-02 14:03:41 +09:00
Bill Currie bfeece3255 Fix the bogus declarations of obj_msgSend and obj_msgSend_super. 2011-03-02 12:35:10 +09:00