Open-source News

Zstd Compressed Firmware Submitted For Linux 5.19, Other Driver Core Changes

Phoronix - Fri, 06/03/2022 - 21:50
Greg Kroah-Hartman has gotten onto submitting his feature pull requests to Linux 5.19 for various areas of the kernel he oversees. With the driver core changes with this new kernel is now the ability to compress firmware files using the popular Zstd...

SiFive RISC-V Sees Some Performance Improvements On Ubuntu 22.04

Phoronix - Fri, 06/03/2022 - 19:50
While SiFive has sadly shutdown production on the current HiFive Unmatched development board in order to focus on new products expected later this year, those with a SiFive HiFive Unmatched RISC-V developer board can enjoy seeing continued performance improvements with newer Linux distributions. Here is a look at the SiFive FU740 SoC performance under the recently released Ubuntu 22.04 LTS compared to the prior 21.10 and 20.04 releases.

NTFS3 Kernel Driver Sees Fixes Sent In For Linux 5.19

Phoronix - Fri, 06/03/2022 - 19:37
Following the recent concerns around maintenance for the NTFS3 kernel driver and other developers stepping up to maintain the "NTFS3" kernel driver contributed by Paragon Software, there is now a batch of fixes ready to go for Linux 5.19...

Ubuntu 22.10 Looking At Replacing WPA With IWD For Linux Wireless

Phoronix - Fri, 06/03/2022 - 18:08
Adding to the list of planned changes for the Ubuntu 22.10 release this October is transitioning from WPA_Supplicant to Intel's IWD daemon for Linux wireless needs...

AMD Preparing To Finally Support Virtual NMI With Their CPUs (VNMI)

Phoronix - Fri, 06/03/2022 - 17:21
It appears that with upcoming AMD Zen 4 processors there will finally be Virtual NMI (VNMI) support for virtualization, a feature Intel CPUs have supported for well more than the past decade...

Premium Special To Celebrate Phoronix's 18th Birthday

Phoronix - Fri, 06/03/2022 - 15:30
This Sunday, 5 June, marks the 18th birthday for Phoronix.com since I started this website to focus on Linux hardware reviews and performance testing. To mark the occasion, there will be a Phoronix Premium special if you wish to go ad-free on the site and enjoy multi-page articles on a single page while helping to hopefully ensure a successful 19th year for Phoronix...

Fedora Server 37 Looking At Providing A KVM-Optimized Image

Phoronix - Fri, 06/03/2022 - 15:00
Fedora Server working group stakeholders are looking at offering an optimized KVM VM disk image as part of their offerings with the F37 release later this year...

How static linking works on Linux

opensource.com - Fri, 06/03/2022 - 15:00
How static linking works on Linux Jayashree Hutt… Fri, 06/03/2022 - 03:00 Register or Login to like Register or Login to like

Code for applications written using C usually has multiple source files, but ultimately you will need to compile them into a single executable.

You can do this in two ways: by creating a static library or a dynamic library (also called a shared library). These two types of libraries vary in terms of how they are created and linked. Your choice of which to use depends on your use case.

In a previous article, I demonstrated how to create a dynamically linked executable, which is the more commonly used method. In this article, I explain how to create a statically linked executable.

Programming and development Red Hat Developers Blog Programming cheat sheets Try for free: Red Hat Learning Subscription eBook: An introduction to programming with Bash Bash shell scripting cheat sheet eBook: Modernizing Enterprise Java Using a linker with static libraries

A linker is a command that combines several pieces of a program together and reorganizes the memory allocation for them.

The functions of a linker include:

  • Integrating all the pieces of a program
  • Figuring out a new memory organization so that all the pieces fit together
  • Reviving addresses so that the program can run under the new memory organization
  • Resolving symbolic references

As a result of all these linker functionalities, a runnable program called an executable is created.

Static libraries are created by copying all necessary library modules used in a program into the final executable image. The linker links static libraries as a last step in the compilation process. An executable is created by resolving external references, combining the library routines with program code.

Create the object files

Here's an example of a static library, along with the linking process. First, create the header file mymath.h with these function signatures:

int add(int a, int b);
int sub(int a, int b);
int mult(int a, int b);
int divi(int a, int b);

Create add.c, sub.c , mult.c and divi.c with these function definitions:

// add.c
int add(int a, int b){
return (a+b);
}

//sub.c
int sub(int a, int b){
return (a-b);
}

//mult.c
int mult(int a, int b){
return (a*b);
}

//divi.c
int divi(int a, int b){
return (a/b);
}

Now generate object files add.o, sub.o, mult.o, and divi.o using GCC:

$ gcc -c add.c sub.c mult.c divi.c

The -c option skips the linking step and creates only object files.

Create a static library called libmymath.a, then remove the object files, as they're no longer required. (Note that using a trash command is safer than rm.)

$ ar rs libmymath.a add.o sub.o mult.o divi.o
$ trash *.o
$ ls
add.c  divi.c  libmymath.a  mult.c  mymath.h  sub.c

You have now created a simple example math library called libmymath, which you can use in C code. There are, of course, very complex C libraries out there, and this is the process their developers use to generate the final product that you and I install for use in C code.

Next, use your math library in some custom code and then link it.

Create a statically linked application

Suppose you've written a command for mathematics. Create a file called mathDemo.c and paste this code into it:

#include
#include
#include

int main()
{
  int x, y;
  printf("Enter two numbers\n");
  scanf("%d%d",&x,&y);
 
  printf("\n%d + %d = %d", x, y, add(x, y));
  printf("\n%d - %d = %d", x, y, sub(x, y));
  printf("\n%d * %d = %d", x, y, mult(x, y));

  if(y==0){
    printf("\nDenominator is zero so can't perform division\n");
      exit(0);
  }else{
      printf("\n%d / %d = %d\n", x, y, divi(x, y));
      return 0;
  }
}

Notice that the first line is an include statement referencing, by name, your own libmymath library.

Create an object file called mathDemo.o for mathDemo.c:

$ gcc -I . -c mathDemo.c

The -I option tells GCC to search for header files listed after it. In this case, you're specifying the current directory, represented by a single dot (.).

Link mathDemo.o with libmymath.a to create the final executable. There are two ways to express this to GCC.

You can point to the files:

$ gcc -static -o mathDemo mathDemo.o libmymath.a

Alternately, you can specify the library path along with the library name:

$ gcc -static -o mathDemo -L . mathDemo.o -lmymath

In the latter example, the -lmymath option tells the linker to link the object files present in the libmymath.a with the object file mathDemo.o to create the final executable. The -L option directs the linker to look for libraries in the following argument (similar to what you would do with -I).

Analyzing the result

Confirm that it's statically linked using the file command:

$ file mathDemo
mathDemo: ELF 64-bit LSB executable, x86-64...
statically linked, with debug_info, not stripped

Using the ldd command, you can see that the executable is not dynamically linked:

$ ldd ./mathDemo
        not a dynamic executable

You can also check the size of the mathDemo executable:

$ du -h ./mathDemo
932K    ./mathDemo

In the example from my previous article, the dynamic executable took up just 24K.

Run the command to see it work:

$ ./mathDemo
Enter two numbers
10
5

10 + 5 = 15
10 - 5 = 5
10 * 5 = 50
10 / 5 = 2

Looks good!

When to use static linking

Dynamically linked executables are generally preferred over statically linked executables because dynamic linking keeps an application's components modular. Should a library receive a critical security update, it can be easily patched because it exists outside of the applications that use it.

When you use static linking, a library's code gets "hidden" within the executable you create, meaning the only way to patch it is to re-compile and re-release a new executable every time a library gets an update—and you have better things to do with your time, trust me.

However, static linking is a reasonable option if the code of a library exists either in the same code base as the executable using it or in specialized embedded devices that are expected to receive no updates.

Learn how to combine multiple C object files into a single executable with static libraries.

Image by:

Image by Mapbox Uncharted ERG, CC-BY 3.0 US

Programming Linux What to read next How dynamic linking for modular libraries works on Linux This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Linux 5.19 Completes Multi-Platform Support For Intel PXA/XScale, HPE GXP SoC Added

Phoronix - Fri, 06/03/2022 - 12:00
Another set of Arm SoC and platform changes have been submitted for the in-development Linux 5.19 merge window...

Why Do Enterprises Use and Contribute to Open Source Software

The Linux Foundation - Fri, 06/03/2022 - 04:44

When people find out I work at the Linux Foundation they invariably ask what we do? Sometimes it is couched around the question, As in the Linux operating system? I explain open source software and try to capture the worldwide impact into 20 seconds before I lose their attention. If they happen to stick around for more, we often dig into the question, Why would enterprises want to participate in open source software projects or use open source software? The reality is – they do, whether they know it or not. And the reality is thousands of companies donate their code to open source projects and invest time and resources helping to further develop and improve open source software.

How extensively used is open source software

To quote from our recently released report, A Guide to Enterprise Open Source, “Open source software (OSS) has transformed our world and become the backbone of our digital economy and the foundation of our digital world. From the Internet and the mobile apps we use daily to the operating systems and programming languages we use to build the future, OSS has played a vital role. It is the lifeblood of the technology industry. Today, OSS powers the digital economy and enables scientific and technological breakthroughs that improve our lives. It’s in our phones, our cars, our airplanes, our homes, our businesses, and our governments. But just over two decades ago, few people had ever heard of OSS, and its use was limited to a small group of dedicated enthusiasts.”

Open source software (OSS) has transformed our world and become the backbone of our digital economy and the foundation of our digital world.

But what does this look like practically:

  • In vertical software stacks across industries, open source penetration ranges from 20 to 85 percent of the overall software used
  • Linux fuels 90%+ of web servers and Internet-connected devices
  • The Android mobile operating system is built on the Linux kernel
  • Immensely popular libraries and tools to build web applications, such as: AMP, Appium, Dojo, jQuery, Marko, Node.js and so many more are open source
  • The world’s top 100 supercomputers run Linux
  • 100% of mainframe customers use Linux
  • The major cloud-service providers – AWS, Google, and Microsoft – all utilize open-source software to run their services and host open-source solutions delivered through the cloud
Why do companies want to participate in open source software projects

Companies primarily participate in open source software projects in three ways:

  1. They donate software they created to the open source community
  2. They provide direct funding and/or allocate software developers and other staff to contribute to open source software projects

The question often asked is, why wouldn’t they want to keep all of their software proprietary or only task their employees to work on their proprietary software?

The 30,000-foot answer is that it is about organizations coming together to collectively solve common problems so they can separately innovate and differentiate on top of the common baseline. They see that they are better off pooling resources to make the baseline better. Sometimes it is called “coopetition.” It generally means that while companies may be in competition with each other in certain areas, they can still cooperate on others.

It is about organizations coming together to collectively solve common problems so they can separately innovate and differentiate

Some old-school examples of this principle:

  • Railroads agreed on a common track size and build so they can all utilize the same lines and equipment was interchangeable
  • Before digital cameras, companies innovated and differentiated on film and cameras, but they all agreed on the spacing for the sprockets to advance the film
  • The entertainment industry united around the VHS and Blu-Ray formats over their rivals

Now, we see companies, organizations, and individuals coming together to solve problems while simultaneously improving their businesses and products:

  • Let’s Encrypt is a free, automated, and open certificate authority with the goal of dramatically increasing the use of secure web protocols by making it much easier and less expensive to setup. They are serving 225+ million websites, issuing ~1.5 million certificates each day on average.
  • The Academy Software Foundation creates value in the film industry through collectively engineering software that powers much of the entertainment, gaming, and media industry productions and open standards needed for growth.
  • The Hyperledger Foundation hosts enterprise-grade blockchain software projects, notably using significantly fewer energy resources than other popular solutions.
  • LF Energy is making the electric grid more modular, interoperable, and scalable to help increase the use of renewable energy sources
  • Dronecode is enabling the development of drone software so companies can use their resources to innovate further
  • OpenSSF is the top technology companies coming together to strengthen the security and resiliency of open source software
  • Kubernetes was donated by Google and is the go-to solution for managing cloud-based software

These are just a small sampling of the open source software projects that enterprises are participating in. You can explore all of the ones hosted at the Linux Foundation here.

How can companies effectively use and participate in open source software projects?

Enterprises looking to better utilize and participate in open source projects can look to the Linux Foundation’s resources to help. Much of what organizations need to know is provided in the just-published report, A Guide to Enterprise Open Source. The report is packed with information and insights from open source leaders at top companies with decades of combined experience. It includes chapters on these topics:

  • Leveraging Open Source Software
  • Preparing the Enterprise for Open Source
  • Developing an Open Source Strategy
  • Setting Up Your Infrastructure for Implementation
  • Setting Up Your Talent for Success
  • Challenges

Additionally, the Linux Foundation offers many open source training courses, events throughout the year, the LFX Platform, and hosts projects that help organizations manage open source utilization and participation, such as:

  • The TODO Group provides resources to setup and run an open source program office, including their extensive guides
  • The Openchain Project maintains an international standard for sharing what software package licenses are included in a larger package, including information on the various licensing requirements so enterprises can ensure they are complying with all of the legal requirements
  • The FinOps Foundation is fostering an, “evolving cloud financial management discipline and cultural practice that enables organizations to get maximum business value by helping engineering, finance, technology, and business teams to collaborate on data-driven spending decisions.”
  • The Software Data Package Exchange (SPDX) is an open standard for communication software bill of materials (SBOMs) so it is clear to every user which pieces of software are included in the overall package.

Again, this is just a snippet of the projects at the Linux Foundation that are working to help organizations adapt, utilize, contribute, and donate open source projects.

The bottom line: Enterprises are increasingly turning to open source software projects to solve common problems and innovate beyond the baseline, and the Linux Foundation is here to help.

The post Why Do Enterprises Use and Contribute to Open Source Software appeared first on Linux Foundation.

Pages