This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: Fix invalid loader fixups from shared libobjc with hpux 10.20
- To: shebs at apple dot com (Stan Shebs)
- Subject: Re: PATCH: Fix invalid loader fixups from shared libobjc with hpux 10.20
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- Date: Thu, 31 May 2001 17:59:44 -0400 (EDT)
- Cc: gcc-patches at gcc dot gnu dot org
I have revised the patch. This is for the 3.0 branch. For the main,
only the last two hunks are applicable.
> Geoff K already checked in a patch right around the first hunk - please
> update your sources and recheck, because part of the code you're
> patching no longer exists.
I reworked Geoff's patch for the branch. It also resolves the section
problem for the address constant. Thus, it should be preferred for
the sake of compatibility.
> > I also noted that the class reference labels were output without changing
> > to the readonly data section. On the HP, they were going into the $CODE$
> > subspace (the text section).
>
> The second hunk looks OK to me, although just for paranoia's sake it
> would be good to have a Linux build/test (any arch) for the branch.
I also reworked this part. On inspection of the hppa assembler code,
I noticed that there was no alignment output for __objc_class_name_Object.
I presume for example that __objc_class_name_Object is a handle for
_OBJC_CLASS_NAME_0 and that the addresses should be the same. The lack
of alignment alignment output for __objc_class_name_Object could cause
the addresses to differ.
The code is now modified to use a declaration for __objc_class_name_Object
to generate the label. The decl for __objc_class_name_Object has the same
type and therefore alignment as _OBJC_CLASS_NAME_0. The dont_output_data
mode of assemble_variable is used so that __objc_class_name_Object and
_OBJC_CLASS_NAME_0 are now at the same address. As a side benefit,
debugging information for the symbol should now be correct although
I haven't checked this. Setting DECL_INITIAL to error_mark_node is
necessary for it to go in the readonly section when possible.
I have built and checked this change under hppa1.1-hp-hpux10.20 and
i686-pc-linux-gnu. No testsuite errors were observed using -static,
-threads (-pthreads), -fPIC or "". I have also examined the assembler
output from Object.m to see that it looks ok.
This fixes a critical usage problem under hppa1.1-hp-hpux10.20 and I
believe therefore that it should be installed on the branch.
Dave
--
J. David Anglin dave.anglin@nrc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
2001-05-31 John David Anglin <dave@hiauly1.hia.nrc.ca>
* objc/objc-act.c (handle_class_ref): Use rest_of_decl_compilation
so that CHOOSE_SECTION gets used.
(handle_impent): Use assemble_variable to put the global objc class
and category name labels in the readonly data section.
--- objc-act.c.orig Tue May 1 19:06:28 2001
+++ objc-act.c Thu May 31 16:22:28 2001
@@ -8362,19 +8362,16 @@
pushdecl (decl);
rest_of_decl_compilation (decl, 0, 0, 0);
- /* Make following constant read-only (why not)? */
- readonly_data_section ();
-
+ /* Make a decl for the address. */
+ sprintf (string, "%sobjc_class_ref_%s",
+ (flag_next_runtime ? "." : "__"), name);
exp = build1 (ADDR_EXPR, string_type_node, decl);
+ decl = build_decl (VAR_DECL, get_identifier (string), string_type_node);
+ DECL_INITIAL (decl) = exp;
+ TREE_STATIC (decl) = 1;
- /* Align the section properly. */
- assemble_constant_align (exp);
-
- /* Inform the assembler about this new external thing. */
- assemble_external (decl);
-
- /* Output a constant to reference this address. */
- output_constant (exp, int_size_in_bytes (string_type_node));
+ pushdecl (decl);
+ rest_of_decl_compilation (decl, 0, 0, 0);
}
else
{
@@ -8414,10 +8411,19 @@
else
{
+ tree decl;
+
sprintf (string, "%sobjc_class_name_%s",
(flag_next_runtime ? "." : "__"), class_name);
- assemble_global (string);
- assemble_label (string);
+
+ decl = build_decl (VAR_DECL, get_identifier (string),
+ build_array_type (char_type_node, 0));
+ TREE_PUBLIC (decl) = 1;
+ TREE_READONLY (decl) = 1;
+ TREE_CONSTANT (decl) = 1;
+ DECL_INITIAL (decl) = error_mark_node;
+
+ assemble_variable (decl, 1, 0, 1);
}
}
@@ -8447,11 +8453,20 @@
else
{
+ tree decl;
+
sprintf (string, "%sobjc_category_name_%s_%s",
(flag_next_runtime ? "." : "__"),
class_name, class_super_name);
- assemble_global (string);
- assemble_label (string);
+
+ decl = build_decl (VAR_DECL, get_identifier (string),
+ build_array_type (char_type_node, 0));
+ TREE_PUBLIC (decl) = 1;
+ TREE_READONLY (decl) = 1;
+ TREE_CONSTANT (decl) = 1;
+ DECL_INITIAL (decl) = error_mark_node;
+
+ assemble_variable (decl, 1, 0, 1);
}
}
}