30

où ça l'erreur ?

31

t'as oublié le xdef _main
avatar
<<< Kernel Extremis©®™ >>> et Inventeur de la différence administratif/judiciaire ! (©Yoshi Noir)

<Vertyos> un poil plus mais elle suce bien quand même la mienne ^^
<Sabrina`> tinkiete flan c juste qu'ils sont jaloux que je te trouve aussi appétissant

32

bizarre que ça donne ça comme bug confus
avatar
<<< Kernel Extremis©®™ >>> et Inventeur de la différence administratif/judiciaire ! (©Yoshi Noir)

<Vertyos> un poil plus mais elle suce bien quand même la mienne ^^
<Sabrina`> tinkiete flan c juste qu'ils sont jaloux que je te trouve aussi appétissant

33

tripaf c quoi cette mauvaise blague hum2 ... tigcc ne pouvait pas me le dire ...

34

pencil
avatar
<<< Kernel Extremis©®™ >>> et Inventeur de la différence administratif/judiciaire ! (©Yoshi Noir)

<Vertyos> un poil plus mais elle suce bien quand même la mienne ^^
<Sabrina`> tinkiete flan c juste qu'ils sont jaloux que je te trouve aussi appétissant

35

k² , pense tu regler ce probleme un jour ?

36

1. userlib::idle_loop ne sert pas à grand chose, utilise plutôt doorsos::ngetchx.
2. OS.h est le mauvais header pour programmer en mode kernel, il faut utiliser doorsos.h. OS.h est pour le _nostub.
3. Je ne peux rien faire pour le problème de _main. Si tu n'exportes pas _main, pour résoudre la référence dans le header kernel, le linker importe le fichier objet correspondant du code de démarrage de tigcc.a:
Section
  File: ..\lib\tigcc.a
  Startup Section: 1
  Can Cut Ranges
  Data
   __startup_entry_point:
   _main:
   ..\lib\tigcc.a _st1: (local)

Et ce fichier objet est obligé d'exporter _main pour les mêmes raisons pour lesquelles tu es obligé de l'exporter. Or, comme il n'est pas possible de linker des programmes kernel sans tigcc.a parce que le header et le stub kernel sont aussi dans tigcc.a, il ne peut pas y avoir de warning ou erreur pour cette erreur d'utilisateur.
avatar
Mes news pour calculatrices TI: Ti-Gen
Mes projets PC pour calculatrices TI: TIGCC, CalcForge (CalcForgeLP, Emu-TIGCC)
Mes chans IRC: #tigcc et #inspired sur irc.freequest.net (UTF-8)

Liberté, Égalité, Fraternité

37

4.
Flanker :
t'as oublié le xdef _main

Non, ce n'est pas ça le problème. TIGCC met _main juste après le stub en ce cas (pour les raisons expliquées dans le 3.). Le problème avec userlib est ailleurs (sur la calculatrice, ce n'est pas un problème de compilation).
avatar
Mes news pour calculatrices TI: Ti-Gen
Mes projets PC pour calculatrices TI: TIGCC, CalcForge (CalcForgeLP, Emu-TIGCC)
Mes chans IRC: #tigcc et #inspired sur irc.freequest.net (UTF-8)

Liberté, Égalité, Fraternité

38

c'est tellement pas ça le problème que dès qu'on rajoute xdef _main ça marche. Quand on ne le met pas, il y a bien le relogement, mais le nom de la lib foire (il commence par un zéro,mais je sais pas si tout est mis à zéro)
avatar
<<< Kernel Extremis©®™ >>> et Inventeur de la différence administratif/judiciaire ! (©Yoshi Noir)

<Vertyos> un poil plus mais elle suce bien quand même la mienne ^^
<Sabrina`> tinkiete flan c juste qu'ils sont jaloux que je te trouve aussi appétissant

39

Bon, en fait il y a 3 cas:
* xdef _main présent: fichier normal
* pas de xdef _main, pas de --remove-unused: fichier normal (identique au précédent), parce que la section .text est rajoutée juste après la section _st1
* pas de xdef _main, --remove-unused: la section .text est virée car non référencée (seuls le header kernel, le stub kernel et la section _st1 contenant seulement des labels, dont _main, reste) -> programme kernel vide (même pas de rts) -> plante si on le lance
avatar
Mes news pour calculatrices TI: Ti-Gen
Mes projets PC pour calculatrices TI: TIGCC, CalcForge (CalcForgeLP, Emu-TIGCC)
Mes chans IRC: #tigcc et #inspired sur irc.freequest.net (UTF-8)

Liberté, Égalité, Fraternité

40

mais là, y a quand même la table de relogement des libs dynamique, donc preos ne peut pas lancer le prog, c'est ça ?
avatar
<<< Kernel Extremis©®™ >>> et Inventeur de la différence administratif/judiciaire ! (©Yoshi Noir)

<Vertyos> un poil plus mais elle suce bien quand même la mienne ^^
<Sabrina`> tinkiete flan c juste qu'ils sont jaloux que je te trouve aussi appétissant

41

Non, la section est complètement supprimée, y compris la référence vers userlib. Mais j'ai vu qu'il y a un bogue: __ld_referenced_lib_count vaut 1, alors qu'il y n'y a aucune librairie encore référencée, donc la bonne valeur serait 0. Je vais corriger ce problème. Mais ça ne va pas résoudre son problème de base (qu'il faut exporter _main).
avatar
Mes news pour calculatrices TI: Ti-Gen
Mes projets PC pour calculatrices TI: TIGCC, CalcForge (CalcForgeLP, Emu-TIGCC)
Mes chans IRC: #tigcc et #inspired sur irc.freequest.net (UTF-8)

Liberté, Égalité, Fraternité

42

ça venait donc de là ?
sinon, c'est pas très grave, faudrait peut-être juste mettre un truc dans la doc pour expliquer ça
avatar
<<< Kernel Extremis©®™ >>> et Inventeur de la différence administratif/judiciaire ! (©Yoshi Noir)

<Vertyos> un poil plus mais elle suce bien quand même la mienne ^^
<Sabrina`> tinkiete flan c juste qu'ils sont jaloux que je te trouve aussi appétissant

43

Voilà corrigé:
diff -ur ld-tigcc/constmrg.c ld-tigcc.refcountfix/constmrg.c
--- ld-tigcc/constmrg.c	Sun Jul 25 15:37:08 2004
+++ ld-tigcc.refcountfix/constmrg.c	Tue Aug  3 00:07:06 2004
@@ -103,8 +103,6 @@
 						// Delete Constant2.
 						if (Constant2Length == Section2->Size)
 						{
-							// The section is no longer referenced.
-							Section2->Referenced = FALSE;
 							// Free the section.
 							FreeSection (Section2);
 						}
@@ -136,8 +134,6 @@
 						// Delete Constant1.
 						if (Constant1Length == Section1->Size)
 						{
-							// The section is no longer referenced.
-							Section1->Referenced = FALSE;
 							// Free the section.
 							FreeSection (Section1);
 						}
@@ -208,8 +204,6 @@
 						// Delete Constant1.
 						if (Constant1Length == Section1->Size)
 						{
-							// The section is no longer referenced.
-							Section1->Referenced = FALSE;
 							// Free the section.
 							FreeSection (Section1);
 						}
@@ -223,8 +217,6 @@
 						// Delete Constant2.
 						if (Constant2Length == Section2->Size)
 						{
-							// The section is no longer referenced.
-							Section2->Referenced = FALSE;
 							// Free the section.
 							FreeSection (Section2);
 						}
diff -ur ld-tigcc/manip.c ld-tigcc.refcountfix/manip.c
--- ld-tigcc/manip.c	Sun Jul 25 15:36:32 2004
+++ ld-tigcc.refcountfix/manip.c	Tue Aug  3 00:25:06 2004
@@ -73,7 +73,6 @@
 	for (Section = GetLast (Program->Sections); Section; Section = NextSection)
 	{
 		NextSection = GetPrev (Section);
-		Section->Referenced = FALSE;
 		FreeSection (Section);
 	}
 	
@@ -81,15 +80,12 @@
 	memset (Program, 0, sizeof (PROGRAM));
 }
 
-// Free a section. Works only if it is not referenced.
-BOOLEAN FreeSection (SECTION *Section)
+// Free a section. The section is assumed not to be referenced. Use
+// RemoveSectionIfUnused instead if the section might still be referenced.
+void FreeSection (SECTION *Section)
 {
 	PROGRAM *Program = Section->Parent;
 	
-	// Don't even try to free the section if it might be referenced.
-	if (Section->Referenced)
-		return FALSE;
-	
 	// Need to free the data, if any.
 	if (Section->Data)
 		free (Section->Data);
@@ -132,8 +128,6 @@
 	
 	Unlink (Program->Sections, Section);
 	free (Section);
-	
-	return TRUE;
 }
 
 // Free a relocation entry.
@@ -176,6 +170,48 @@
 	Location->SymbolName = (Location->Symbol ? Location->Symbol->Name : NULL);
 }
 
+// Free a section if it is no longer referenced. Update the ReferencedLibCount
+// accordingly.
+BOOLEAN RemoveSectionIfUnused (SECTION *Section)
+{
+	PROGRAM *Program = Section->Parent;
+	SECTION *OtherSection;
+	LIB_CALL *LibCall, *OtherSecLibCall;
+	
+	// Don't free the section if it is still referenced.
+	if (Section->Referenced)
+		return FALSE;
+
+	// If this section references any libraries, and if it was the last one to
+	// reference them, we need to mark the library as no longer referenced.
+	for_each (LibCall, Section->LibCalls)
+	{
+		LIBRARY *Library = LibCall->Library;
+		if (Library->Referenced)
+		{
+			for_each (OtherSection, Program->Sections)
+			{
+				// Not this section!
+				if (OtherSection == Section) continue;
+				for_each (OtherSecLibCall, OtherSection->LibCalls)
+				{
+					// If this library is still referenced, forget it.
+					if (OtherSecLibCall->Library == Library) goto NextLibCall;
+				}
+			}
+			// The library is no longer referenced after this section is removed.
+			Library->Referenced = FALSE;
+			Program->Libraries.ReferencedCount--;
+		}
+NextLibCall:;
+	}
+
+	// Now free the section.
+	FreeSection (Section);
+	
+	return TRUE;
+}
+
 // Create a section symbol for the given section, if none has been
 // created yet. If there already is one, set its name accordingly.
 // Return the section symbol.
@@ -741,7 +777,7 @@
 		NextSection = GetNext (Section);
 		
 		// Remove the section if it is unused.
-		FreeSection (Section);
+		RemoveSectionIfUnused (Section);
 	}
 }
 
@@ -913,7 +949,6 @@
 	Dest->Relocs.EmittedCount    += Src->Relocs.EmittedCount;
 	
 	// Free the source section.
-	Src->Referenced = FALSE;
 	FreeSection (Src);
 	
 	return Dest;
diff -ur ld-tigcc/manip.h ld-tigcc.refcountfix/manip.h
--- ld-tigcc/manip.h	Wed Apr  7 19:44:56 2004
+++ ld-tigcc.refcountfix/manip.h	Tue Aug  3 00:17:28 2004
@@ -24,8 +24,9 @@
 
 // Free the program tree.
 void FreeProgram (PROGRAM *Program);
-// Free a section. Works only if it is not referenced.
-BOOLEAN FreeSection (SECTION *Section);
+// Free a section. The section is assumed not to be referenced. Use
+// RemoveSectionIfUnused instead if the section might still be referenced.
+void FreeSection (SECTION *Section);
 // Free a relocation entry.
 void FreeReloc (RELOC *Reloc);
 // Free the relation reference of a relocation entry, and set it to
@@ -35,6 +36,10 @@
 // If a symbol is already known, set the symbol name to its name.
 // Decrease the number of unresolved relocs in the section.
 void FreeLocationSymbolName (SECTION *Section, LOCATION *Location);
+
+// Free a section if it is no longer referenced. Update the ReferencedLibCount
+// accordingly.
+BOOLEAN RemoveSectionIfUnused (SECTION *Section);
 
 // Create a section symbol for the given section, if none has been
 // created yet. If there already is one, set its name accordingly.
avatar
Mes news pour calculatrices TI: Ti-Gen
Mes projets PC pour calculatrices TI: TIGCC, CalcForge (CalcForgeLP, Emu-TIGCC)
Mes chans IRC: #tigcc et #inspired sur irc.freequest.net (UTF-8)

Liberté, Égalité, Fraternité