From: Matt H. <ma...@cs...> - 2006-10-21 20:24:14
|
> -----Original Message----- > From: cil...@li... > [mailto:cil...@li...] On Behalf Of > Dan...@al... > Sent: Thursday, October 19, 2006 2:37 AM > To: cil...@li... > Subject: [CIL users] Wrong CIL transformation > > Hi all, > > I've run into a buggy CIL transformation for a global var, > which is not referenced in this file, but referenced from > other files in the project. > There are 2 problems: > - CIL does not keep the original var. name, so linking will > fail because there is no var with the original name in the > transformed source file > - the newly created vars can occur in different source files > with the same name, which again gives linker problems because > the same global var is defined in several files. > > Does anyone know a workaround or a fix? > > Thanks, > Dany > Following up ... Your second point is definitely a bug. The new vars should have been static. Here is a patch. Matt --- src/frontc/cabs2cil.ml 18 May 2006 03:25:13 -0000 1.469 +++ src/frontc/cabs2cil.ml 21 Oct 2006 20:22:53 -0000 @@ -3280,7 +3280,12 @@ let spec_res = doSpecList "" s' in let se1 = if !scopes == [] then begin - ignore (createGlobal spec_res + (* This is a global. Mark the new vars as static *) + let spec_res' = + let t, sto, inl, attrs = spec_res in + t, Static, inl, attrs + in + ignore (createGlobal spec_res' ((newvar, dt', [], cabslu), ie')); empty end else |